Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | From 3e2b745020c2dbf0201fe7df3dad9e7e0b2e1bb6 Mon Sep 17 00:00:00 2001 |
| 2 | From: Michael Niedermayer <michaelni@gmx.at> |
| 3 | Date: Fri, 3 Oct 2014 17:35:58 +0200 |
| 4 | Subject: [PATCH] avcodec/pngdec: Check bits per pixel before setting |
| 5 | monoblack pixel format |
| 6 | |
| 7 | (Upstream commit 3e2b745020c2dbf0201fe7df3dad9e7e0b2e1bb6) |
| 8 | |
| 9 | Fixes out of array accesses |
| 10 | Fixes: asan_heap-oob_14dbfcf_4_asan_heap-oob_1ce5767_179_add_method_small.png |
| 11 | |
| 12 | Upstream-Status: Backport |
| 13 | |
| 14 | Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind |
| 15 | Signed-off-by: Michael Niedermayer <michaelni@gmx.at> |
| 16 | Signed-off-by: Yue Tao <yue.tao@windriver.com> |
| 17 | --- |
| 18 | libavcodec/pngdec.c | 2 +- |
| 19 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 20 | |
| 21 | diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c |
| 22 | index da91aab..f3603b3 100644 |
| 23 | --- a/gst-libs/ext/libav/libavcodec/pngdec.c |
| 24 | +++ b/gst-libs/ext/libav/libavcodec/pngdec.c |
| 25 | @@ -481,7 +481,7 @@ static int decode_frame(AVCodecContext *avctx, |
| 26 | } else if (s->bit_depth == 16 && |
| 27 | s->color_type == PNG_COLOR_TYPE_RGB) { |
| 28 | avctx->pix_fmt = PIX_FMT_RGB48BE; |
| 29 | - } else if (s->bit_depth == 1 && |
| 30 | + } else if (s->bit_depth == 1 && s->bits_per_pixel == 1 && |
| 31 | s->color_type == PNG_COLOR_TYPE_GRAY) { |
| 32 | avctx->pix_fmt = PIX_FMT_MONOBLACK; |
| 33 | } else if (s->color_type == PNG_COLOR_TYPE_PALETTE) { |
| 34 | -- |
| 35 | 1.7.9.5 |
| 36 | |