avformat/mpsubdec: Use av_sat_add/sub64() in fracval handling

Fixes: signed integer overflow: 9223372036850000000 + 9000000 cannot be represented in type 'long long'
Fixes: 26910/clusterfuzz-testcase-minimized-ffmpeg_dem_MPSUB_fuzzer-665448017480908

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 463e024363)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2021-01-16 21:48:57 +01:00
parent 146e353d9c
commit 293222d8be
1 changed files with 2 additions and 2 deletions

View File

@ -72,8 +72,8 @@ static int parse_line(const char *line, int64_t *value, int64_t *value2)
fracval *= 10;
for (;p2 - p1 > 7 + 1; p1++)
fracval /= 10;
if (intval > 0) intval += fracval;
else intval -= fracval;
if (intval > 0) intval = av_sat_add64(intval, fracval);
else intval = av_sat_sub64(intval, fracval);
line += p2;
} else
line += p1;