wmaenc: require a large enough output buffer to prevent overwrites
authorJustin Ruggles <justin.ruggles@gmail.com>
Fri, 2 Mar 2012 21:33:33 +0000 (16:33 -0500)
committerReinhard Tartler <siretart@tauware.de>
Sun, 4 Mar 2012 20:26:29 +0000 (21:26 +0100)
The maximum theoretical frame size is around 17000 bytes. Although in
practice it will generally be much smaller, we require a larger buffer
just to be safe.

CC: libav-stable@libav.org
(cherry picked from commit dfc4fdedf8cfc56a505579b1f2c1c5efbce4b97e)

Signed-off-by: Reinhard Tartler <siretart@tauware.de>
libavcodec/wmaenc.c

index c762a72..a9053bb 100644 (file)
@@ -355,6 +355,11 @@ static int encode_superframe(AVCodecContext *avctx,
         }
     }
 
+    if (buf_size < 2 * MAX_CODED_SUPERFRAME_SIZE) {
+        av_log(avctx, AV_LOG_ERROR, "output buffer size is too small\n");
+        return AVERROR(EINVAL);
+    }
+
 #if 1
     total_gain= 128;
     for(i=64; i; i>>=1){