avformat/matroskadec: Fix float-cast-overflow undefined behavior in matroska_parse_tr...
authorNikolas Bowe <nbowe-at-google.com@ffmpeg.org>
Thu, 18 Jan 2018 23:21:56 +0000 (15:21 -0800)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 8 Jul 2018 11:07:06 +0000 (13:07 +0200)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit e07649e618caedc07eaf2f4d09253de7f77d14f0)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/matroskadec.c

index fe23f39..d6e093e 100644 (file)
@@ -1952,8 +1952,16 @@ static int matroska_parse_tracks(AVFormatContext *s)
         }
 
         if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
-            if (!track->default_duration && track->video.frame_rate > 0)
-                track->default_duration = 1000000000 / track->video.frame_rate;
+            if (!track->default_duration && track->video.frame_rate > 0) {
+                double default_duration = 1000000000 / track->video.frame_rate;
+                if (default_duration > UINT64_MAX || default_duration < 0) {
+                    av_log(matroska->ctx, AV_LOG_WARNING,
+                         "Invalid frame rate %e. Cannot calculate default duration.\n",
+                         track->video.frame_rate);
+                } else {
+                    track->default_duration = default_duration;
+                }
+            }
             if (track->video.display_width == -1)
                 track->video.display_width = track->video.pixel_width;
             if (track->video.display_height == -1)