From patchwork Sat Jun 6 18:08:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 20178 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 64C2244A843 for ; Sat, 6 Jun 2020 21:09:22 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 42B5F68B014; Sat, 6 Jun 2020 21:09:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe02-1.mx.upcmail.net (vie01a-dmta-pe02-1.mx.upcmail.net [62.179.121.157]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 569C968AED1 for ; Sat, 6 Jun 2020 21:09:16 +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 1jhdFs-00028K-0E for ffmpeg-devel@ffmpeg.org; Sat, 06 Jun 2020 20:09:16 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id hdEujAi4b6Jy6hdEujgFCk; Sat, 06 Jun 2020 20:08:16 +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=Bqd_Mx51fNNRogZe5GsA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=jd6J4Gguk5HxikPWLKER:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 6 Jun 2020 20:08:13 +0200 Message-Id: <20200606180815.12736-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfMVJhKFy+hvPg2j5Y0YV1E2BgQLaz4UsNqnlNI/WstwtlWmXf98tmCslosv31D25nrUwfxk409U/xVfuzOmHg2o31eFuNToTAxu4OGDHT5FDnQ7tUFPZ ss9s/hHIcYDH4dZh8vAA6/Pyf88iYGppcw9/SAg0fDZBTJjocDdN3YSd Subject: [FFmpeg-devel] [PATCH 1/3] avformat/oggdec: Initialize return value from ogg_read_page() and check it everywhere 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 regression since 9ad47762c17d2c6d06595aa17b88112baa91b72c Fixes: out of array access Fixes: 22172/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5658535590625280 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/oggdec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index b4ba00df61..f65013f55e 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -412,6 +412,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid, int probing) if (idx < 0) av_free(readout_buf); avio_seek(bc, start_pos, SEEK_SET); + *sid = -1; return 0; } @@ -422,6 +423,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid, int probing) if (idx < 0) av_free(readout_buf); avio_seek(bc, start_pos, SEEK_SET); + *sid = -1; return 0; } @@ -661,7 +663,7 @@ static int ogg_get_length(AVFormatContext *s) ogg->page_pos = -1; while (!ogg_read_page(s, &i, 1)) { - if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 && + if (i >= 0 && ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 && ogg->streams[i].codec) { s->streams[i]->duration = ogg_gptopts(s, i, ogg->streams[i].granule, NULL); From patchwork Sat Jun 6 18:08:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 20179 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 5599544A843 for ; Sat, 6 Jun 2020 21:09:23 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 37DA568B0B6; Sat, 6 Jun 2020 21:09:23 +0300 (EEST) 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 4664868B079 for ; Sat, 6 Jun 2020 21:09:17 +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 1jhdFt-0001Gv-0J for ffmpeg-devel@ffmpeg.org; Sat, 06 Jun 2020 20:09:17 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id hdEujAi5W6Jy6hdEujgFD2; Sat, 06 Jun 2020 20:08:17 +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=XWcubQRAXv8Rzqd7M6sA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=UDnyf2zBuKT2w-IlGP_r:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 6 Jun 2020 20:08:14 +0200 Message-Id: <20200606180815.12736-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200606180815.12736-1-michael@niedermayer.cc> References: <20200606180815.12736-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfBCHWdhPWtdXQnok5xGeLhE5MfCElE1HHQqVTBqF6TZT6+jZcgj3FRCRzfww+kw/dGW9QGaTzJVkVtibM2kK2tb/uXQUQ2aUOoSQeg5Wt2VVYubatzHL mwpmPaXosD4sYvz/VqjE5/hyt5BnboHUYFR420tWcGMAyZeF3vFedIIF Subject: [FFmpeg-devel] [PATCH 2/3] avformat/oggdec: Do not hardcode arbitrary and sometimes unavailable 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" Fixes: regression since e983197cbc93420b67aa7e811be47d7278c2c8a2 Fixes: out of array read Fixes: 22185/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5662069073641472 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/oggdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index f65013f55e..bd4311bb41 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -206,7 +206,7 @@ static const struct ogg_codec *ogg_find_codec(uint8_t *buf, int size) * situation where a new audio stream spawn (identified with a new serial) and * must replace the previous one (track switch). */ -static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic, +static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic, int magic_size, int probing) { struct ogg *ogg = s->priv_data; @@ -220,7 +220,7 @@ static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, char *magic, } /* Check for codecs */ - codec = ogg_find_codec(magic, 8); + codec = ogg_find_codec(magic, magic_size); if (!codec && !probing) { av_log(s, AV_LOG_ERROR, "Cannot identify new stream\n"); return AVERROR_INVALIDDATA; @@ -430,7 +430,7 @@ static int ogg_read_page(AVFormatContext *s, int *sid, int probing) /* CRC is correct so we can be 99% sure there's an actual change here */ if (idx < 0) { if (data_packets_seen(ogg)) - idx = ogg_replace_stream(s, serial, readout_buf, probing); + idx = ogg_replace_stream(s, serial, readout_buf, size, probing); else idx = ogg_new_stream(s, serial); From patchwork Sat Jun 6 18:08:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 20180 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 7531944A843 for ; Sat, 6 Jun 2020 21:09:24 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6474468B0C4; Sat, 6 Jun 2020 21:09:24 +0300 (EEST) 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 7F15B68B0B6 for ; Sat, 6 Jun 2020 21:09:17 +0300 (EEST) 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 1jhdFt-0005hA-0J for ffmpeg-devel@ffmpeg.org; Sat, 06 Jun 2020 20:09:17 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id hdEvjAi5g6Jy6hdEvjgFD5; Sat, 06 Jun 2020 20:08:17 +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=Zd_JTcUzVhF4Iu9hD_UA:9 a=pHzHmUro8NiASowvMSCR:22 a=Ew2E2A-JSTLzCXPT_086:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 6 Jun 2020 20:08:15 +0200 Message-Id: <20200606180815.12736-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200606180815.12736-1-michael@niedermayer.cc> References: <20200606180815.12736-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfBCHWdhPWtdXQnok5xGeLhE5MfCElE1HHQqVTBqF6TZT6+jZcgj3FRCRzfww+kw/dGW9QGaTzJVkVtibM2kK2tb/uXQUQ2aUOoSQeg5Wt2VVYubatzHL mwpmPaXosD4sYvz/VqjE5/hyt5BnboHUYFR420tWcGMAyZeF3vFedIIF Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/mpeg12dec: remove outdated comments 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" Found-by: Kieran Signed-off-by: Michael Niedermayer --- libavcodec/mpeg12dec.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index 40d054def5..ff81364fd1 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -221,7 +221,6 @@ end: } /** - * Note: this function can read out of range and crash for corrupt streams. * Changing this would eat up any speed benefits it has. * Do not use "fast" flag if you need the code to be robust. */ @@ -397,7 +396,6 @@ end: } /** - * Note: this function can read out of range and crash for corrupt streams. * Changing this would eat up any speed benefits it has. * Do not use "fast" flag if you need the code to be robust. */ @@ -559,7 +557,6 @@ static inline int mpeg2_decode_block_intra(MpegEncContext *s, } /** - * Note: this function can read out of range and crash for corrupt streams. * Changing this would eat up any speed benefits it has. * Do not use "fast" flag if you need the code to be robust. */