avformat/hls: Check seg size and offset for overflow

Fixes: integer overflow
Fixes: signed integer overflow: 9223372036854775807 + 2039324394 cannot be represented in type 'int64_t' (aka 'long')

Found-by:  continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer
2025-12-22 23:59:53 +01:00
committed by michaelni
parent 8ac6325143
commit d1985442e1

View File

@@ -975,6 +975,10 @@ static int parse_playlist(HLSContext *c, const char *url,
ptr = strchr(ptr, '@');
if (ptr)
seg_offset = strtoll(ptr+1, NULL, 10);
if (seg_size < 0 || seg_offset > INT64_MAX - seg_size) {
ret = AVERROR_INVALIDDATA;
goto fail;
}
} else if (av_strstart(line, "#", NULL)) {
av_log(c->ctx, AV_LOG_VERBOSE, "Skip ('%s')\n", line);
continue;