Skip to content

Commit

Permalink
base64Decode: clearer error message when an invalid character is dete…
Browse files Browse the repository at this point in the history
…cted

Output the offending string in its entirety to provide context.

Closes #8479

(cherry picked from commit dc3ccf0)
  • Loading branch information
brianmcgee authored and mergify[bot] committed Sep 17, 2024
1 parent 0446f7b commit 0a92a12
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 @@ -200,8 +200,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 0a92a12

Please sign in to comment.