]> git.sesse.net Git - ffmpeg/commitdiff
dpcm: Round output buffer size up.
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 26 Jan 2012 16:04:51 +0000 (17:04 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 26 Jan 2012 16:05:57 +0000 (17:05 +0100)
Fixes: CVE-2011-3951
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/dpcm.c

index 929458a22b2d4d6a1eed2345c76daf329e652bbb..82402210764406c8628ab0c6bc04a6a9ba56233f 100644 (file)
@@ -205,9 +205,12 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
         av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
         return AVERROR(EINVAL);
     }
+    if (out % s->channels) {
+        av_log(avctx, AV_LOG_WARNING, "channels have differing number of samples\n");
+    }
 
     /* get output buffer */
-    s->frame.nb_samples = out / s->channels;
+    s->frame.nb_samples = (out + s->channels - 1) / s->channels;
     if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) {
         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
         return ret;