summaryrefslogtreecommitdiff
path: root/libavcodec/pngdec.c
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-11-06 23:44:01 +0100
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-11-07 13:15:14 +0100
commit3e8e1a660ea182111057d56ec1cfad2c62250f4c (patch)
treeaed3cdcd453d018ed071f394aa5fd78ddd0118fb /libavcodec/pngdec.c
parentdb374790c75fa4ef947abcb5019fcf21d0b2de85 (diff)
downloadffmpeg-3e8e1a660ea182111057d56ec1cfad2c62250f4c.tar.gz
apng: use correct size for output buffer
The buffer needs s->bpp bytes, at maximum currently 10. Assert that s->bpp is not larger. This fixes a stack buffer overflow. Reviewed-by: wm4 <nfxjfg@googlemail.com> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Diffstat (limited to 'libavcodec/pngdec.c')
-rw-r--r--libavcodec/pngdec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 689aa2b562..feb17630a2 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -1016,7 +1016,7 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s,
for (x = s->x_offset; x < s->x_offset + s->cur_w; ++x, foreground += s->bpp, background += s->bpp) {
size_t b;
uint8_t foreground_alpha, background_alpha, output_alpha;
- uint8_t output[4];
+ uint8_t output[10];
// Since we might be blending alpha onto alpha, we use the following equations:
// output_alpha = foreground_alpha + (1 - foreground_alpha) * background_alpha
@@ -1056,6 +1056,8 @@ static int handle_p_frame_apng(AVCodecContext *avctx, PNGDecContext *s,
output_alpha = foreground_alpha + FAST_DIV255((255 - foreground_alpha) * background_alpha);
+ av_assert0(s->bpp <= 10);
+
for (b = 0; b < s->bpp - 1; ++b) {
if (output_alpha == 0) {
output[b] = 0;