From patchwork Sun Sep 18 17:14:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 38014 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp791147pzh; Sun, 18 Sep 2022 10:15:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7y58qPppwmT0sOQM2jkfKFqen7Gy6mtRaRCqacKrJ7OvxiImQ33roCha+tBECTjgV9LneV X-Received: by 2002:a50:c8c3:0:b0:44c:5cb6:5484 with SMTP id k3-20020a50c8c3000000b0044c5cb65484mr12258556edh.285.1663521331273; Sun, 18 Sep 2022 10:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663521331; cv=none; d=google.com; s=arc-20160816; b=eLiTe+jpHLnJLrJQ2+NqryN8DMu8d/gW45FTMKQE+mVwlHwmLD25a2VbdGoMLGwhg1 h3ItkekEPUBdJAqtJmwhH5j+rs1sW+9gz2rQnQC0FLhWiC9F4VW79XI+nMJAgpk1q84D 4hSwXKA8+Yv1HWwFzrMvaRer3mu5uxjE0o3wq4bWcHlS08wwnrrd3Ye6BRvGvLKHt8sF /Cw0FF1fu5+DNeeWdEEu2wzJ3SPgEF/OHG745/qR1sOVmjIRmlk7AGfcDcyKfBrJ3VYg KAsz99+p6pNyj8tUjYEbYAtsc/9AV60IlpIRlJxVGhoKEvmTn+3Td7ZcbPu0BKGFmgDe gXLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=F/bOgiJhSWggnhwr8vBghNsNksIW8/M1KotVd9qiyxk=; b=J/STNms8floM8HpgoZ7T8wtojNgrXCIqCbnQXgLSeBZXb4jCiF2j/KTMCOnKYv4/aY 7W4eaV4yfWaY1uPATkg8lpzZbmGtSngO+z2Vcu8HCySeUO59dlU8W/N+/35XEjgaxEYN +bIAQ3mdJOva4yNQRx+3wfWv4a260M+8zVEOeRkTy++mQav85zLaP+tymoVpOsm72LDF f42W4jM5iW3b7gWsmFchVw+oYTNe43h3GJZuVwLDtNENrpqzNFYJd2YsUmwM3p2VzPYp 44ye9BN5y4/p8kaYLHIJFISLYoI7JUg1p9JkqZPAupiTxCSFBMF+xh2yBwsRHme9LcMH 1iOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z1-20020a05640240c100b00446190ccceesi9246142edb.10.2022.09.18.10.15.30; Sun, 18 Sep 2022 10:15:31 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F282968BBB4; Sun, 18 Sep 2022 20:14:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-at03-1.mx.upcmail.net (vie01a-dmta-at03-1.mx.upcmail.net [62.179.121.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 92B4968BAB9 for ; Sun, 18 Sep 2022 20:14:13 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-at03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1oZxrx-00EpEO-4a for ffmpeg-devel@ffmpeg.org; Sun, 18 Sep 2022 19:14:13 +0200 Received: from ren-mail-psmtp-mg01. ([80.109.253.241]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id Zxrtom0058s8UZxrxoH67C; Sun, 18 Sep 2022 19:14:13 +0200 Received: from localhost ([213.47.68.29]) by ren-mail-psmtp-mg01. with ESMTP id ZxrwoprDYOG5ZZxrxonHih; Sun, 18 Sep 2022 19:14:13 +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.4 cv=KJo5sHJo c=1 sm=1 tr=0 ts=632751e5 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=NEAV23lmAAAA:8 a=NshO9-A1oeDdFREysYEA:9 a=gwxJs2bdBLB-eNNpozNY:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 18 Sep 2022 19:14:07 +0200 Message-Id: <20220918171410.31835-10-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220918171410.31835-1-michael@niedermayer.cc> References: <20220918171410.31835-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfDbd5uOikFynSxtcRSdV7B3YQPfN2yNcUeVdyOi4L3ghNI+dmAB/widXj3Yt8dy6gVCIJOfoL2QXr2T8rMztHUDDxKZvjB6j6Rpq9ZA5v9kzp1ia7DSg Wapp+4xdzDUAurop/nMq9tLLeCRI4Kx8GVkrVJPIElWgQuuy+GSfsI+B53cnSgDriDwmBX9qBzW1bg== Subject: [FFmpeg-devel] [PATCH 10/13] avformat/vividas: Check packet size X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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" X-TUID: 49LB6KTBAvru Fixes: signed integer overflow: 119760682 - -2084600173 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-6745781167587328 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, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/vividas.c b/libavformat/vividas.c index e9954f73ed0..22f61db7576 100644 --- a/libavformat/vividas.c +++ b/libavformat/vividas.c @@ -643,7 +643,9 @@ static int viv_read_packet(AVFormatContext *s, if (viv->current_audio_subpacket < viv->n_audio_subpackets) { AVStream *astream; - int size = viv->audio_subpackets[viv->current_audio_subpacket+1].start - viv->audio_subpackets[viv->current_audio_subpacket].start; + int64_t size = viv->audio_subpackets[viv->current_audio_subpacket+1].start - (int64_t)viv->audio_subpackets[viv->current_audio_subpacket].start; + if (size < 0 || size != (int)size) + return AVERROR_INVALIDDATA; pb = viv->sb_pb; ret = av_get_packet(pb, pkt, size);