diff mbox series

[FFmpeg-devel,1/3] avformat/flvdec: Check data before casting

Message ID 20210608192941.15327-1-michael@niedermayer.cc
State Accepted
Commit 1e24da5cfe1cec70e322b93578227465f325936e
Headers show
Series [FFmpeg-devel,1/3] avformat/flvdec: Check data before casting | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Michael Niedermayer June 8, 2021, 7:29 p.m. UTC
Fixes: -nan is outside the range of representable values of type 'long'
Fixes: signed integer overflow: 1000 * -9223372036854775808 cannot be represented in type 'long'
Fixes: 34890/clusterfuzz-testcase-minimized-ffmpeg_dem_FLV_fuzzer-5334208657620992

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavformat/flvdec.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer June 12, 2021, 3:55 p.m. UTC | #1
On Tue, Jun 08, 2021 at 09:29:39PM +0200, Michael Niedermayer wrote:
> Fixes: -nan is outside the range of representable values of type 'long'
> Fixes: signed integer overflow: 1000 * -9223372036854775808 cannot be represented in type 'long'
> Fixes: 34890/clusterfuzz-testcase-minimized-ffmpeg_dem_FLV_fuzzer-5334208657620992
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavformat/flvdec.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

will apply patchset


[...]
diff mbox series

Patch

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 6bd6c8c944..60d1a5c654 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -682,7 +682,11 @@  static int amf_parse_object(AVFormatContext *s, AVStream *astream,
             av_dict_set(&s->metadata, key, str_val, 0);
         } else if (amf_type == AMF_DATA_TYPE_STRING) {
             av_dict_set(&s->metadata, key, str_val, 0);
-        } else if (amf_type == AMF_DATA_TYPE_DATE) {
+        } else if (   amf_type == AMF_DATA_TYPE_DATE
+                   && isfinite(date.milliseconds)
+                   && date.milliseconds > INT64_MIN/1000
+                   && date.milliseconds < INT64_MAX/1000
+                  ) {
             // timezone is ignored, since there is no easy way to offset the UTC
             // timestamp into the specified timezone
             avpriv_dict_set_timestamp(&s->metadata, key, 1000 * (int64_t)date.milliseconds);