ffmdec: make sure the time base is valid
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Sun, 8 Mar 2015 22:12:59 +0000 (23:12 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 22 Apr 2015 10:27:24 +0000 (12:27 +0200)
A negative time base can trigger assertions.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 4c91d81be23ffacfa3897b2bcfa77445bb0c2f89)

Conflicts:

libavformat/ffmdec.c
(cherry picked from commit 9678ceb6976ca8194848b24535785a298521211f)

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavformat/ffmdec.c

index 09a76e5..5196e1d 100644 (file)
@@ -295,6 +295,11 @@ static int ffm2_read_header(AVFormatContext *s)
             case MKBETAG('S', 'T', 'V', 'I'):
                 codec->time_base.num = avio_rb32(pb);
                 codec->time_base.den = avio_rb32(pb);
             case MKBETAG('S', 'T', 'V', 'I'):
                 codec->time_base.num = avio_rb32(pb);
                 codec->time_base.den = avio_rb32(pb);
+                if (codec->time_base.num <= 0 || codec->time_base.den <= 0) {
+                    av_log(s, AV_LOG_ERROR, "Invalid time base %d/%d\n",
+                           codec->time_base.num, codec->time_base.den);
+                    goto fail;
+                }
                 codec->width = avio_rb16(pb);
                 codec->height = avio_rb16(pb);
                 codec->gop_size = avio_rb16(pb);
                 codec->width = avio_rb16(pb);
                 codec->height = avio_rb16(pb);
                 codec->gop_size = avio_rb16(pb);
@@ -419,6 +424,11 @@ static int ffm_read_header(AVFormatContext *s)
         case AVMEDIA_TYPE_VIDEO:
             codec->time_base.num = avio_rb32(pb);
             codec->time_base.den = avio_rb32(pb);
         case AVMEDIA_TYPE_VIDEO:
             codec->time_base.num = avio_rb32(pb);
             codec->time_base.den = avio_rb32(pb);
+            if (codec->time_base.num <= 0 || codec->time_base.den <= 0) {
+                av_log(s, AV_LOG_ERROR, "Invalid time base %d/%d\n",
+                       codec->time_base.num, codec->time_base.den);
+                goto fail;
+            }
             codec->width = avio_rb16(pb);
             codec->height = avio_rb16(pb);
             codec->gop_size = avio_rb16(pb);
             codec->width = avio_rb16(pb);
             codec->height = avio_rb16(pb);
             codec->gop_size = avio_rb16(pb);