Check for overflow in parsing skip/until specification (#584)

Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=57259
This commit is contained in:
Martijn van Beurden 2023-04-10 08:08:54 +02:00 committed by GitHub
parent f191bc3d6c
commit 4b2c33ebf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -56,8 +56,12 @@ static FLAC__bool local__parse_uint64_(const char *s, FLAC__uint64 *value)
return false;
while('\0' != (c = *s++))
if(c >= '0' && c <= '9')
if(c >= '0' && c <= '9') {
FLAC__uint64 tmp = ret;
ret = ret * 10 + (c - '0');
if(ret < tmp) /* check for overflow */
return false;
}
else
return false;
@ -300,6 +304,8 @@ FLAC__bool flac__utils_parse_skip_until_specification(const char *s, utils__Skip
if(local__parse_uint64_(s, &val)) {
spec->value_is_samples = true;
if(val > INT64_MAX)
return false;
spec->value.samples = (FLAC__int64)val;
if(is_negative)
spec->value.samples = -(spec->value.samples);