Skip to content

Commit

Permalink
Merge pull request NixOS#8766 from brianmcgee/fix/base64-decode-error…
Browse files Browse the repository at this point in the history
…-message

base64Decode: clearer error message when an invalid character is detected
  • Loading branch information
Ericson2314 authored Sep 17, 2024
2 parents 3fb6605 + dc3ccf0 commit 95f2b2b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libutil/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,9 @@ std::string base64Decode(std::string_view s)
if (c == '\n') continue;

char digit = base64DecodeChars[(unsigned char) c];
if (digit == npos)
throw Error("invalid character in Base64 string: '%c'", c);
if (digit == npos) {
throw Error("invalid character in Base64 string: '%c' in '%s'", c, s.data());
}

bits += 6;
d = d << 6 | digit;
Expand Down

0 comments on commit 95f2b2b

Please sign in to comment.