avformat/img2dec: improve bmp probe
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 4 Jul 2014 02:54:52 +0000 (04:54 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 4 Jul 2014 02:54:52 +0000 (04:54 +0200)
fix probetest failure

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

index cc53409..b1fa8cc 100644 (file)
@@ -564,13 +564,20 @@ AVInputFormat ff_image2pipe_demuxer = {
 static int bmp_probe(AVProbeData *p)
 {
     const uint8_t *b = p->buf;
+    int ihsize;
 
-    if (AV_RB16(b) == 0x424d)
-        if (!AV_RN32(b + 6)) {
-            return AVPROBE_SCORE_EXTENSION + 1;
-        } else {
-            return AVPROBE_SCORE_EXTENSION / 4;
-        }
+    if (AV_RB16(b) != 0x424d)
+        return 0;
+
+    ihsize = AV_RL32(b+14);
+    if (ihsize < 12 || ihsize > 255)
+        return 0;
+
+    if (!AV_RN32(b + 6)) {
+        return AVPROBE_SCORE_EXTENSION + 1;
+    } else {
+        return AVPROBE_SCORE_EXTENSION / 4;
+    }
     return 0;
 }