From 3c63d06d81e7b4ff8f37c0a3cc344d6a80f72928 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 8 Jul 2015 17:49:00 +0200 Subject: avcodec/h264_slice: Fix container cropping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes out of array read Fixes: asan_heap-oob_394322e_138_cov_4265020547_CVPCMNL1_SVA_C.264 Found-by: Samuel Groß, Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer --- libavcodec/h264_slice.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libavcodec/h264_slice.c') diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 4b6c2170d0..10a50bbfc7 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -980,7 +980,10 @@ static int init_dimensions(H264Context *h) /* handle container cropping */ if (FFALIGN(h->avctx->width, 16) == FFALIGN(width, 16) && - FFALIGN(h->avctx->height, 16) == FFALIGN(height, 16)) { + FFALIGN(h->avctx->height, 16) == FFALIGN(height, 16) && + h->avctx->width <= width && + h->avctx->height <= height + ) { width = h->avctx->width; height = h->avctx->height; } -- cgit v1.2.3