Berry remove overflow check when parsing hex (#23842)

This commit is contained in:
s-hadinger 2025-08-27 20:43:54 +02:00 committed by GitHub
parent 5d9e62eebe
commit a07b293a9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 2 deletions

View File

@ -301,9 +301,7 @@ BERRY_API bint be_str2int(const char *str, const char **endstr)
/* hex literal */
str += 2; /* skip 0x or 0X */
while ((c = be_char2hex(*str++)) >= 0) {
if (sum > M_IMAX / 16) goto overflow_pos;
sum = sum * 16 + c;
if (sum < 0) goto overflow_pos; /* overflow check */
}
if (endstr) {
*endstr = str - 1;

View File

@ -12,3 +12,4 @@ assert(int("0x00") == 0)
assert(int("0X1") == 1)
assert(int("0x000000F") == 15)
assert(int("0x1000") == 0x1000)
assert(int("0xFF00FF00") == 0xFF00FF00)