aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-10-03 17:35:58 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-12-21 04:40:04 +0100
commit0b99a18ebc4109574ae4a619ba3716208d367e70 (patch)
treeb2ab82f581f740ccf5c3c737e476b0b977b7030e
parentaa17021e812eb2527033d85ba0390cc4f7d6c9d5 (diff)
downloadffmpeg-0b99a18ebc4109574ae4a619ba3716208d367e70.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>
-rw-r--r--libavcodec/pngdec.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 4740932c41..2180f66979 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -634,7 +634,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) {