From patchwork Wed Oct 21 22:37:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 23136 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 17E3344B350 for ; Thu, 22 Oct 2020 01:38:43 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F2C6068B4AB; Thu, 22 Oct 2020 01:38:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe01-1.mx.upcmail.net (vie01a-dmta-pe01-1.mx.upcmail.net [62.179.121.154]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4BA9B680951 for ; Thu, 22 Oct 2020 01:38:35 +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 1kVMkd-0009xM-0J for ffmpeg-devel@ffmpeg.org; Thu, 22 Oct 2020 00:38:35 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id VMjfkGJrvIr7GVMjfk5WO5; Thu, 22 Oct 2020 00:37:35 +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=QN4WuTDL 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=B61Ovn-cpUVBVQ0K5kIA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=UDnyf2zBuKT2w-IlGP_r:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 22 Oct 2020 00:37:33 +0200 Message-Id: <20201021223733.2563-9-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201021223733.2563-1-michael@niedermayer.cc> References: <20201021223733.2563-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfJPjhi0qO83qSiyR3ErhVyOl6QGeaXsmtjgIo2TGXWqAkmv3eNlyfjfVhsEZ5F6wmDhR6IDj6LCH8gO1jo7HlKRSps8nTfd2Nr6/KQgXl67ZzbmVkazX uGBJwndbz5ZFfTr8LY9LX12eCx+R2OWgVbasK535vy6iXwC1/yc861l1 Subject: [FFmpeg-devel] [PATCH 9/9] avformat/vividas: better check of current_sb_entry 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" This is the simplest fix for the problem, it is possible to instead check this when the variables are set and propagate errors and then fail earlier Fixes: out of array access Fixes: 26490/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5723367078100992 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/vividas.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/vividas.c b/libavformat/vividas.c index 6e93d96aef..83d0ed1167 100644 --- a/libavformat/vividas.c +++ b/libavformat/vividas.c @@ -673,6 +673,10 @@ static int viv_read_packet(AVFormatContext *s, if (!pb) return AVERROR(EIO); off = avio_tell(pb); + + if (viv->current_sb_entry >= viv->n_sb_entries) + return AVERROR_INVALIDDATA; + off += viv->sb_entries[viv->current_sb_entry].size; if (viv->sb_entries[viv->current_sb_entry].flag == 0) {