From patchwork Mon Apr 20 22:03:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 19116 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id B28354496CE for ; Tue, 21 Apr 2020 01:04:48 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8C19568B8C1; Tue, 21 Apr 2020 01:04:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-1.mx.upcmail.net (vie01a-dmta-pe03-1.mx.upcmail.net [62.179.121.160]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E421468B51A for ; Tue, 21 Apr 2020 01:04:42 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1jQeWw-0009C3-0O for ffmpeg-devel@ffmpeg.org; Tue, 21 Apr 2020 00:04:42 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id QeVxjk4SH6Jy6QeVyjIhtv; Tue, 21 Apr 2020 00:03:42 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=GKl27dFK c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=qxjvbh_5br_V2ABs-cgA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 21 Apr 2020 00:03:39 +0200 Message-Id: <20200420220341.7729-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfNPqfcWuifJcNtP9veXz5xB7Ff/dpae9oYH2mjlXzVlq8BPBp9e/g7PjGy4wdqEZJerLIhijpCvbk2LtJfBM0eMOQaLo/OZBKJnKB5s8Q+e8phTwXvTt 11NgPv/BOe3WOWNdUEkhXYvWZQbQ5SgtA2lwRa9hGfCO1Ufylxcbw+TS Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/iff: Fix invalid pointer intermediates in decode_deep_rle32() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Michael Niedermayer --- libavcodec/iff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index acd6519b06..2e65e266d0 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -715,7 +715,7 @@ static void decode_deep_rle32(uint8_t *dst, const uint8_t *src, int src_size, in { const uint8_t *src_end = src + src_size; int x = 0, y = 0, i; - while (src + 5 <= src_end) { + while (src_end - src >= 5) { int opcode; opcode = *(int8_t *)src++; if (opcode >= 0) { From patchwork Mon Apr 20 22:03:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 19118 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id AE79A4496CE for ; Tue, 21 Apr 2020 01:04:51 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 99C7768B8F2; Tue, 21 Apr 2020 01:04:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe02-2.mx.upcmail.net (vie01a-dmta-pe02-2.mx.upcmail.net [62.179.121.158]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AD39368B81E for ; Tue, 21 Apr 2020 01:04:43 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe02.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1jQeWx-0003D8-69 for ffmpeg-devel@ffmpeg.org; Tue, 21 Apr 2020 00:04:43 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id QeVzjk4Ul6Jy6QeVzjIhwN; Tue, 21 Apr 2020 00:03:43 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=GKl27dFK c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=79iuu2szTDDSE-IKk3QA:9 a=1V7CHTTZMrDe-GDH:21 a=mQvMoJxcCetJpwV8:21 a=1fhp2MxaeJtTNGEnv6mo:22 a=GiHQeXbIydbNWtWbTz-1:22 a=p-dnK0njbqwfn1k4-x12:22 a=7aar8cbMflRChVwg8ngv:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 21 Apr 2020 00:03:40 +0200 Message-Id: <20200420220341.7729-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420220341.7729-1-michael@niedermayer.cc> References: <20200420220341.7729-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfO5E23l9+swpytKcnpJpA3rmmFDIfz8XYTdwwASEd6u+g9sjPuWq70QvyP00zq/FfTQdpXDR9sCRWR+Xaq10aoAA97i8HECrFJaINtQP+3U0KA5CVUSO ZgYDRAQDmwvGRfegrcv/nqbCTcbeDGvv5AE5X1gpEQAvNNR3JEjZStnj Subject: [FFmpeg-devel] [PATCH 2/3] avcodec/iff: Check length before memcpy() in decode_deep_rle32() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes: out of array read Fixes: 20796/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5111364702175232.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/iff.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 2e65e266d0..23d19d8a25 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -722,6 +722,8 @@ static void decode_deep_rle32(uint8_t *dst, const uint8_t *src, int src_size, in int size = opcode + 1; for (i = 0; i < size; i++) { int length = FFMIN(size - i, width); + if (src_end - src < length) + return; memcpy(dst + y*linesize + x * 4, src, length * 4); src += length * 4; x += length; From patchwork Mon Apr 20 22:03:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 19117 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id D09394496CE for ; Tue, 21 Apr 2020 01:04:50 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BD54568B8C6; Tue, 21 Apr 2020 01:04:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-1.mx.upcmail.net (vie01a-dmta-pe03-1.mx.upcmail.net [62.179.121.160]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7FFFE68B81E for ; Tue, 21 Apr 2020 01:04:43 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1jQeWx-0009RF-69 for ffmpeg-devel@ffmpeg.org; Tue, 21 Apr 2020 00:04:43 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id QeVzjk4V16Jy6QeVzjIhwZ; Tue, 21 Apr 2020 00:03:43 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=GKl27dFK c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=HxCeIv3czZbOCgnouvUA:9 a=azJ9AUAQ7r3F7A5q:21 a=12pMHp-91cuBNMSu:21 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=QOGEsqRv6VhmHaoFNykA:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 21 Apr 2020 00:03:41 +0200 Message-Id: <20200420220341.7729-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420220341.7729-1-michael@niedermayer.cc> References: <20200420220341.7729-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfO5E23l9+swpytKcnpJpA3rmmFDIfz8XYTdwwASEd6u+g9sjPuWq70QvyP00zq/FfTQdpXDR9sCRWR+Xaq10aoAA97i8HECrFJaINtQP+3U0KA5CVUSO ZgYDRAQDmwvGRfegrcv/nqbCTcbeDGvv5AE5X1gpEQAvNNR3JEjZStnj Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/cbs_h265_syntax_template: Limit num_long_term_pics more strictly X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The limit is based on hevcdec.c Fixes: 20854/clusterfuzz-testcase-minimized-ffmpeg_BSF_HEVC_METADATA_fuzzer-5160442882424832 Fixes: out of array access Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/cbs_h265_syntax_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/cbs_h265_syntax_template.c b/libavcodec/cbs_h265_syntax_template.c index 180a045c34..b74b9648c3 100644 --- a/libavcodec/cbs_h265_syntax_template.c +++ b/libavcodec/cbs_h265_syntax_template.c @@ -1367,7 +1367,7 @@ static int FUNC(slice_segment_header)(CodedBitstreamContext *ctx, RWContext *rw, infer(num_long_term_sps, 0); idx_size = 0; } - ue(num_long_term_pics, 0, HEVC_MAX_LONG_TERM_REF_PICS); + ue(num_long_term_pics, 0, FFMIN(HEVC_MAX_LONG_TERM_REF_PICS, FF_ARRAY_ELEMS(current->poc_lsb_lt) - current->num_long_term_sps)); for (i = 0; i < current->num_long_term_sps + current->num_long_term_pics; i++) {