diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-10-03 17:35:58 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-10-03 18:29:11 +0200 |
commit | 433e15bb873f7ba54d8895de7e74c43205551084 (patch) | |
tree | ea31fa3ffe8e48c95d5e0d38bde42ffaa7a0fb55 /libavcodec/pngdec.c | |
parent | c3af801c63024c2fcd7a5fbb571b6f8a9c9790dc (diff) | |
download | ffmpeg-433e15bb873f7ba54d8895de7e74c43205551084.tar.gz |
avcodec/pngdec: Check bits per pixel before setting monoblack pixel format
Fixes out of array accesses
Fixes: asan_heap-oob_14dbfcf_4_asan_heap-oob_1ce5767_179_add_method_small.png
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 3e2b745020c2dbf0201fe7df3dad9e7e0b2e1bb6)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pngdec.c')
-rw-r--r-- | libavcodec/pngdec.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c index c92087f5e8..faf938b36e 100644 --- a/libavcodec/pngdec.c +++ b/libavcodec/pngdec.c @@ -644,7 +644,7 @@ static int decode_frame(AVCodecContext *avctx, } else if ((s->bits_per_pixel == 1 || s->bits_per_pixel == 2 || s->bits_per_pixel == 4 || s->bits_per_pixel == 8) && s->color_type == PNG_COLOR_TYPE_PALETTE) { avctx->pix_fmt = AV_PIX_FMT_PAL8; - } else if (s->bit_depth == 1) { + } else if (s->bit_depth == 1 && s->bits_per_pixel == 1) { avctx->pix_fmt = AV_PIX_FMT_MONOBLACK; } else if (s->bit_depth == 8 && s->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) { |