base: don't read past the end of the slice in parse_number_{u64,f64}

This commit is contained in:
sabith saheb committed 2026-10-19 12:59:04 +05:30
1 parent 2a6876f8bb
commit 9d41525a2f
4 files changed
+61 -36

No files matched your search

+14 -18
View File
@@ -21668,14 +21668,12 @@ wuffs_private_impl__high_prec_dec__parse(wuffs_private_impl__high_prec_dec* h,
uint8_t* q = s.ptr + s.len;
if (options & WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_UNDERSCORES) {
for (;; p++) {
if (p >= q) {
return wuffs_base__make_status(wuffs_base__error__bad_argument);
} else if (*p != '_') {
break;
}
for (; (p < q) && (*p == '_'); p++) {
}
}
if (p >= q) {
return wuffs_base__make_status(wuffs_base__error__bad_argument);
}
// Parse sign.
do {
@@ -21688,14 +21686,12 @@ wuffs_private_impl__high_prec_dec__parse(wuffs_private_impl__high_prec_dec* h,
break;
}
if (options & WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_UNDERSCORES) {
for (;; p++) {
if (p >= q) {
return wuffs_base__make_status(wuffs_base__error__bad_argument);
} else if (*p != '_') {
break;
}
for (; (p < q) && (*p == '_'); p++) {
}
}
if (p >= q) {
return wuffs_base__make_status(wuffs_base__error__bad_argument);
}
} while (0);
// Parse digits, up to (and including) a '.', 'E' or 'e'. Examples for each
@@ -21808,14 +21804,12 @@ after_sep:
after_exp:
do {
if (options & WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_UNDERSCORES) {
for (;; p++) {
if (p >= q) {
return wuffs_base__make_status(wuffs_base__error__bad_argument);
} else if (*p != '_') {
break;
}
for (; (p < q) && (*p == '_'); p++) {
}
}
if (p >= q) {
return wuffs_base__make_status(wuffs_base__error__bad_argument);
}
int32_t exp_sign = +1;
if (*p == '+') {
@@ -23585,6 +23579,7 @@ wuffs_base__parse_number_u64(wuffs_base__slice_u8 s, uint32_t options) {
if (p < q) {
goto hexadecimal;
}
goto fail_bad_argument;
} else if ((*p == 'd') || (*p == 'D')) {
p++;
@@ -23595,6 +23590,7 @@ wuffs_base__parse_number_u64(wuffs_base__slice_u8 s, uint32_t options) {
if (p < q) {
goto decimal;
}
goto fail_bad_argument;
}
if (options & WUFFS_BASE__PARSE_NUMBER_XXX__ALLOW_MULTIPLE_LEADING_ZEROES) {