avformat/rsd: Check channels and sample_rate fields
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 6 Nov 2013 10:48:49 +0000 (11:48 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 6 Nov 2013 10:57:57 +0000 (11:57 +0100)
Fixes probetest failure

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

index 37e544a..7fad3e6 100644 (file)
@@ -43,10 +43,13 @@ static const uint32_t rsd_unsupported_tags[] = {
 
 static int rsd_probe(AVProbeData *p)
 {
-    if (!memcmp(p->buf, "RSD", 3) &&
-        p->buf[3] - '0' >= 2 && p->buf[3] - '0' <= 6)
-        return AVPROBE_SCORE_EXTENSION;
-    return 0;
+    if (memcmp(p->buf, "RSD", 3) || p->buf[3] - '0' < 2 || p->buf[3] - '0' > 6)
+        return 0;
+    if (AV_RL32(p->buf +  8) > 256 || !AV_RL32(p->buf +  8))
+        return 1;
+    if (AV_RL32(p->buf + 16) > 8*48000 || !AV_RL32(p->buf + 16))
+        return 1;
+    return AVPROBE_SCORE_EXTENSION;
 }
 
 static int rsd_read_header(AVFormatContext *s)