From patchwork Thu Dec 24 23:24:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 24643 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 A04E544B6C6 for ; Fri, 25 Dec 2020 01:25:27 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6A31C680026; Fri, 25 Dec 2020 01:25:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe01-2.mx.upcmail.net (vie01a-dmta-pe01-2.mx.upcmail.net [62.179.121.155]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A3A9C68AAA8 for ; Fri, 25 Dec 2020 01:25:20 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe01.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1ksZyy-0008Xm-0D for ffmpeg-devel@ffmpeg.org; Fri, 25 Dec 2020 00:25:20 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id sZxzklbbCO4rAsZxzkXzQu; Fri, 25 Dec 2020 00:24:20 +0100 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=RNDN4Lq+ 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=uVPkJj0J2XoHPbMPm7IA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=bWyr8ysk75zN3GCy5bjg:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 25 Dec 2020 00:24:16 +0100 Message-Id: <20201224232419.10369-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfDlM7Gbi2ZsKEKxdwzglEQb7oiaNFsQ07alqW7YWgSDQCWcsNs5/EW7QaVczyNeuM8KM3rzIw40hne/Q9iUh5vQpI2eBm0WgtyYnA8iLf9cwAbHtIYRw 4ymIlc2J79kQXLhRj0uRDSTUMvPz1TmRAty0SPNWWt/H9kbE1zlhpJoj Subject: [FFmpeg-devel] [PATCH 1/4] avformat/mpc8: Check size before implicitly converting to int 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: Timeout Fixes: 28551/clusterfuzz-testcase-minimized-ffmpeg_dem_MPC8_fuzzer-6229183210586112 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/mpc8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mpc8.c b/libavformat/mpc8.c index 447a8d4fdf..ff7da2ef55 100644 --- a/libavformat/mpc8.c +++ b/libavformat/mpc8.c @@ -292,7 +292,7 @@ static int mpc8_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_EOF; mpc8_get_chunk_header(s->pb, &tag, &size); - if (size < 0) + if (size < 0 || size > INT_MAX) return -1; if(tag == TAG_AUDIOPACKET){ if ((ret = av_get_packet(s->pb, pkt, size)) < 0) From patchwork Thu Dec 24 23:24:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 24645 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 15ED74481A5 for ; Fri, 25 Dec 2020 02:48:46 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DE92A68ACE3; Fri, 25 Dec 2020 02:48:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-2.mx.upcmail.net (vie01a-dmta-pe06-2.mx.upcmail.net [84.116.36.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 31C79687F26 for ; Fri, 25 Dec 2020 02:48:40 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1ksZyy-0008WV-0E for ffmpeg-devel@ffmpeg.org; Fri, 25 Dec 2020 00:25:20 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id sZy0klbdUO4rAsZy0kXzRS; Fri, 25 Dec 2020 00:24:20 +0100 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=RNDN4Lq+ 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=5XoJ9KCY64U2T4N_1lYA:9 a=_yFJ9sh8x_SYITJ4:21 a=AxtMKYIDSrmeZUp6:21 a=pHzHmUro8NiASowvMSCR:22 a=Ew2E2A-JSTLzCXPT_086:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 25 Dec 2020 00:24:17 +0100 Message-Id: <20201224232419.10369-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201224232419.10369-1-michael@niedermayer.cc> References: <20201224232419.10369-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfDlM7Gbi2ZsKEKxdwzglEQb7oiaNFsQ07alqW7YWgSDQCWcsNs5/EW7QaVczyNeuM8KM3rzIw40hne/Q9iUh5vQpI2eBm0WgtyYnA8iLf9cwAbHtIYRw 4ymIlc2J79kQXLhRj0uRDSTUMvPz1TmRAty0SPNWWt/H9kbE1zlhpJoj Subject: [FFmpeg-devel] [PATCH 2/4] avcodec/siren: remove constant region_size 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/siren.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libavcodec/siren.c b/libavcodec/siren.c index b1b4944562..0713ef25e7 100644 --- a/libavcodec/siren.c +++ b/libavcodec/siren.c @@ -352,6 +352,7 @@ static const float noise_category6[20] = { }; #define FRAME_SIZE 320 +#define REGION_SIZE 20 typedef struct SirenContext { GetBitContext gb; @@ -361,7 +362,6 @@ typedef struct SirenContext { int number_of_regions; int scale_factor; int sample_rate_bits; - int region_size; unsigned dw1, dw2, dw3, dw4; @@ -402,7 +402,6 @@ static av_cold int siren_init(AVCodecContext *avctx) s->esf_adjustment = 7; s->number_of_regions = 14; s->scale_factor = 22; - s->region_size = 20; s->dw1 = s->dw2 = s->dw3 = s->dw4 = 1; for (i = 0; i < 64; i++) { @@ -574,7 +573,7 @@ static int decode_vector(SirenContext *s, int number_of_regions, for (region = 0; region < number_of_regions; region++) { category = power_categories[region]; - coefs_ptr = coefs + (region * s->region_size); + coefs_ptr = coefs + (region * REGION_SIZE); if (category >= 0 && category < 7) { decoder_tree = decoder_tables[category]; @@ -623,11 +622,11 @@ static int decode_vector(SirenContext *s, int number_of_regions, } } - coefs_ptr = coefs + (region * s->region_size); + coefs_ptr = coefs + (region * REGION_SIZE); if (category == 5) { i = 0; - for (j = 0; j < s->region_size; j++) { + for (j = 0; j < REGION_SIZE; j++) { if (*coefs_ptr != 0) i++; coefs_ptr++; @@ -636,7 +635,7 @@ static int decode_vector(SirenContext *s, int number_of_regions, noise = decoder_standard_deviation[region] * noise_category5[i]; } else if (category == 6) { i = 0; - for (j = 0; j < s->region_size; j++) { + for (j = 0; j < REGION_SIZE; j++) { if (*coefs_ptr++ != 0) i++; } @@ -648,7 +647,7 @@ static int decode_vector(SirenContext *s, int number_of_regions, noise = 0; } - coefs_ptr = coefs + (region * s->region_size); + coefs_ptr = coefs + (region * REGION_SIZE); if (category == 5 || category == 6 || category == 7) { dw1 = get_dw(s); From patchwork Thu Dec 24 23:24:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 24646 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 3611344B578 for ; Fri, 25 Dec 2020 04:36:45 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0D32968AD47; Fri, 25 Dec 2020 04:36:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-2.mx.upcmail.net (vie01a-dmta-pe03-2.mx.upcmail.net [62.179.121.161]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6D28E68A912 for ; Fri, 25 Dec 2020 04:36:38 +0200 (EET) 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 1ksZyy-0004kr-0E for ffmpeg-devel@ffmpeg.org; Fri, 25 Dec 2020 00:25:20 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id sZy0klbdmO4rAsZy0kXzRX; Fri, 25 Dec 2020 00:24:20 +0100 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=RNDN4Lq+ 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=7HNZxg2LfLnDCwJRmB4A:9 a=pHzHmUro8NiASowvMSCR:22 a=Ew2E2A-JSTLzCXPT_086:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 25 Dec 2020 00:24:18 +0100 Message-Id: <20201224232419.10369-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201224232419.10369-1-michael@niedermayer.cc> References: <20201224232419.10369-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfDlM7Gbi2ZsKEKxdwzglEQb7oiaNFsQ07alqW7YWgSDQCWcsNs5/EW7QaVczyNeuM8KM3rzIw40hne/Q9iUh5vQpI2eBm0WgtyYnA8iLf9cwAbHtIYRw 4ymIlc2J79kQXLhRj0uRDSTUMvPz1TmRAty0SPNWWt/H9kbE1zlhpJoj Subject: [FFmpeg-devel] [PATCH 3/4] avcodec/siren: Factorize category 5 and 6 noise computation 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/siren.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/libavcodec/siren.c b/libavcodec/siren.c index 0713ef25e7..1f37305bd1 100644 --- a/libavcodec/siren.c +++ b/libavcodec/siren.c @@ -624,7 +624,7 @@ static int decode_vector(SirenContext *s, int number_of_regions, coefs_ptr = coefs + (region * REGION_SIZE); - if (category == 5) { + if (category == 5 || category == 6) { i = 0; for (j = 0; j < REGION_SIZE; j++) { if (*coefs_ptr != 0) @@ -632,15 +632,10 @@ static int decode_vector(SirenContext *s, int number_of_regions, coefs_ptr++; } - noise = decoder_standard_deviation[region] * noise_category5[i]; - } else if (category == 6) { - i = 0; - for (j = 0; j < REGION_SIZE; j++) { - if (*coefs_ptr++ != 0) - i++; - } - - noise = decoder_standard_deviation[region] * noise_category6[i]; + if (category == 5) { + noise = decoder_standard_deviation[region] * noise_category5[i]; + } else + noise = decoder_standard_deviation[region] * noise_category6[i]; } else if (category == 7) { noise = decoder_standard_deviation[region] * 0.70711f; } else { From patchwork Thu Dec 24 23:24:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 24644 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 8967744AADB for ; Fri, 25 Dec 2020 02:44:20 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6AAF868AAFB; Fri, 25 Dec 2020 02:44:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-2.mx.upcmail.net (vie01a-dmta-pe06-2.mx.upcmail.net [84.116.36.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 60B5B68A9E9 for ; Fri, 25 Dec 2020 02:44:14 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1ksZyy-0000wq-0E for ffmpeg-devel@ffmpeg.org; Fri, 25 Dec 2020 00:25:20 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id sZy0klbdvO4rAsZy0kXzRb; Fri, 25 Dec 2020 00:24:20 +0100 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=RNDN4Lq+ 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=PeJ8rfH0Ox5kDwNwe5gA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=UDnyf2zBuKT2w-IlGP_r:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 25 Dec 2020 00:24:19 +0100 Message-Id: <20201224232419.10369-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201224232419.10369-1-michael@niedermayer.cc> References: <20201224232419.10369-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfDlM7Gbi2ZsKEKxdwzglEQb7oiaNFsQ07alqW7YWgSDQCWcsNs5/EW7QaVczyNeuM8KM3rzIw40hne/Q9iUh5vQpI2eBm0WgtyYnA8iLf9cwAbHtIYRw 4ymIlc2J79kQXLhRj0uRDSTUMvPz1TmRAty0SPNWWt/H9kbE1zlhpJoj Subject: [FFmpeg-devel] [PATCH 4/4] avcodec/siren: Increase noise category 5 and 6 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 entry read is not used in subsequent computation, thus its value is not important. Fixes: out of array read Fixes: 28578/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_SIREN_fuzzer-6332019122503680 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/siren.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/siren.c b/libavcodec/siren.c index 1f37305bd1..7c2800d108 100644 --- a/libavcodec/siren.c +++ b/libavcodec/siren.c @@ -341,12 +341,12 @@ static const float mlt_quant[7][14] = { { 0.0f, 1.964f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f } }; -static const float noise_category5[20] = { +static const float noise_category5[21] = { 0.70711f, 0.6179f, 0.5005f, 0.3220f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f, 0.17678f }; -static const float noise_category6[20] = { +static const float noise_category6[21] = { 0.70711f, 0.5686f, 0.3563f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f, 0.25f };