dpcm: ignore extra unpaired bytes in stereo streams.
authorAlex Converse <alex.converse@gmail.com>
Fri, 17 Feb 2012 22:13:40 +0000 (14:13 -0800)
committerAlex Converse <alex.converse@gmail.com>
Fri, 17 Feb 2012 23:42:23 +0000 (15:42 -0800)
Fixes: CVE-2011-3951

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
libavcodec/dpcm.c

index 1b0f6b0..7f5dbfe 100644 (file)
@@ -183,6 +183,11 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
     int stereo = s->channels - 1;
     int16_t *output_samples;
 
+    if (stereo && (buf_size & 1)) {
+        buf_size--;
+        buf_end--;
+    }
+
     /* calculate output size */
     switch(avctx->codec->id) {
     case CODEC_ID_ROQ_DPCM:
@@ -317,7 +322,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
     *got_frame_ptr   = 1;
     *(AVFrame *)data = s->frame;
 
-    return buf_size;
+    return avpkt->size;
 }
 
 #define DPCM_DECODER(id_, name_, long_name_)                \