lavf/matroskaenc: check for overflow in display width.
authorNicolas George <nicolas.george@normalesup.org>
Wed, 12 Dec 2012 20:19:24 +0000 (21:19 +0100)
committerNicolas George <nicolas.george@normalesup.org>
Thu, 13 Dec 2012 11:45:07 +0000 (12:45 +0100)
libavformat/matroskaenc.c

index adca74f..c0c0a2d 100644 (file)
@@ -637,7 +637,11 @@ static int mkv_write_tracks(AVFormatContext *s)
                 }
 
                 if (st->sample_aspect_ratio.num) {
-                    int d_width = av_rescale(codec->width, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
+                    int64_t d_width = av_rescale(codec->width, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
+                    if (d_width > INT_MAX) {
+                        av_log(s, AV_LOG_ERROR, "Overflow in display width\n");
+                        return AVERROR(EINVAL);
+                    }
                     put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , d_width);
                     put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, codec->height);
                 }