OSDN Git Service

westwood: Make sure audio header info is present when parsing audio packets
authorShitiz Garg <mail@dragooon.net>
Thu, 15 Dec 2011 09:02:59 +0000 (14:32 +0530)
committerMartin Storsjö <martin@martin.st>
Thu, 15 Dec 2011 09:07:20 +0000 (11:07 +0200)
Audio header information might get scrambled and would not parse,
yet wsqva_read_packet would try to parse audio packets causing
segfaults such as floating point exception.

Fixes bugzilla #141.

Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/westwood.c

index 67a00c9..82b7e94 100644 (file)
@@ -326,6 +326,11 @@ static int wsvqa_read_packet(AVFormatContext *s,
         chunk_size = AV_RB32(&preamble[4]);
         skip_byte = chunk_size & 0x01;
 
+        if ((chunk_type == SND2_TAG || chunk_type == SND1_TAG) && wsvqa->audio_channels == 0) {
+            av_log(s, AV_LOG_ERROR, "audio chunk without any audio header information found\n");
+            return AVERROR_INVALIDDATA;
+        }
+
         if ((chunk_type == SND1_TAG) || (chunk_type == SND2_TAG) || (chunk_type == VQFR_TAG)) {
 
             if (av_new_packet(pkt, chunk_size))