avidec: Make sure a packet is large enough before reading its data
authorMartin Storsjö <martin@martin.st>
Fri, 27 Sep 2013 21:41:31 +0000 (00:41 +0300)
committerMartin Storsjö <martin@martin.st>
Sun, 29 Sep 2013 16:56:22 +0000 (19:56 +0300)
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/avidec.c

index 1212c6a..3616281 100644 (file)
@@ -816,7 +816,8 @@ fail:
 
 static int read_gab2_sub(AVStream *st, AVPacket *pkt)
 {
-    if (!strcmp(pkt->data, "GAB2") && AV_RL16(pkt->data + 5) == 2) {
+    if (pkt->size >= 7 &&
+        !strcmp(pkt->data, "GAB2") && AV_RL16(pkt->data + 5) == 2) {
         uint8_t desc[256];
         int score      = AVPROBE_SCORE_EXTENSION, ret;
         AVIStream *ast = st->priv_data;