diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2021-01-26 16:50:10 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2021-09-11 21:23:49 +0200 |
commit | 89e3962271d0f703f226de8d827f62e79def32e0 (patch) | |
tree | aae276fc0e02805b4ef6d20af496f475b806333a | |
parent | a3d5698106a16c6ba84949d3f1d2557c78e1c1e9 (diff) | |
download | ffmpeg-89e3962271d0f703f226de8d827f62e79def32e0.tar.gz |
avformat/flvdec: Check double before cast in parse_keyframes_index()
Fixes: -2.21166e+304 is outside the range of representable values of type 'long'
Fixes: 29169/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5725452796821504
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 09e5e406c7b9d7c1ee97ebae1476a2f68e6a90d1)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/flvdec.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 25ee352f8c..3ba2aedde3 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -426,9 +426,13 @@ static int parse_keyframes_index(AVFormatContext *s, AVIOContext *ioc, int64_t m } for (i = 0; i < arraylen && avio_tell(ioc) < max_pos - 1; i++) { + double d; if (avio_r8(ioc) != AMF_DATA_TYPE_NUMBER) goto invalid; - current_array[0][i] = av_int2double(avio_rb64(ioc)); + d = av_int2double(avio_rb64(ioc)); + if (isnan(d) || d < INT64_MIN || d > INT64_MAX) + goto invalid; + current_array[0][i] = d; } if (times && filepositions) { // All done, exiting at a position allowing amf_parse_object |