add upper-bounds check for valid hex characters

This commit is contained in:
Tim Aitken 2024-02-20 12:40:59 -08:00
parent 157b166e23
commit 7a74a996f3

View File

@ -1692,11 +1692,11 @@ bool OurReader::decodeHexadecimal(Token& token, Value& decoded) {
return addError("Token too long to be unsigned integer.", token, current); return addError("Token too long to be unsigned integer.", token, current);
for (; current < token.end_; ++current) { for (; current < token.end_; ++current) {
Char c = *current; Char c = *current;
if (c >= 'a') if (c >= 'a' && c <= 'f')
c -= 'a' - 10; c -= 'a' - 10;
else if (c >= 'A') else if (c >= 'A' && c <= 'F')
c -= 'A' - 10; c -= 'A' - 10;
else if (c >= '0') else if (c >= '0' && c <= '9')
c -= '0'; c -= '0';
else else
return addError("Contains non-hexadecimal digits.", token, current); return addError("Contains non-hexadecimal digits.", token, current);