From patchwork Sat Sep 30 22:30:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44068 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1204:b0:15d:8365:d4b8 with SMTP id v4csp599005pzf; Sat, 30 Sep 2023 15:31:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5T4CAYJVg3J0SAYCRigVxehBxWn8wxCj9ltshjhnIT12JwlrJEXXheKtCJFkTq+OC8uFD X-Received: by 2002:a17:906:319a:b0:9ae:7943:b0ff with SMTP id 26-20020a170906319a00b009ae7943b0ffmr7214043ejy.27.1696113116957; Sat, 30 Sep 2023 15:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696113116; cv=none; d=google.com; s=arc-20160816; b=Oal6jO4dGK25V/9axi17bRh7sLVjjMEguIyl9+3SNvNlPiUDO4ZEoFJ70GkqnqL0S0 sQjFZfQxsQMlhQ++OtQSxVytSjD2AmhLQ1OzhOujCuT6BnghEg4sKM4BKkn7uVl9s9GJ J2C9b9iCXEqPt8MVpoDNZ/8eLFBnhW1vAMSZQeKX3Oru5GATE4QyCMwOAWnGEuRVS3Y+ OQZMol7DNOBCkZ26Gwd61T6hrAhwNR4p2JI+tVhGDEocnQZM32YXYPg8LZdGwQj1zYBz WaOUn3bVhRMA11EpCLP7+yVlOlaSknIgSZ1x55iASxmMxhWhEkQcfvIwJxUmnDc4HLzz UHYw== 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=IquD4OXH7C9HazBqHmCPsJ+S+CFsiZ5ZHwY3SLbOvKE=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=FLt7iYTFdzs3pJklV0bGTl3AZZzFm4daok5bEjApi6TTrs/YBYzouaBBK96LcgukO+ JthHgLD/kANMTqO8bTWz8dlaPd05bCJyoj+i5H3HMKKeQWmkOuqfSF3U4Qory5QcuTIu 4eEIvQXHx9BbWphnASNPH7fz10mFU0tqtFjezGlyXEIbwS2u0v6htPnpSEObhbA2GNP/ FNnpOf+kFQPlISP0bUGOn/dPTkYBSchsnJdCl7e9XkLfLj7s7JA7TsQB0U8BQ/2jurAk NmhPXQlTUStmq7agqCu6Jq2AmTkqM4Q2F3uJ3f4KYNV2Pj+mPQCd5zI1K7SJ1yoEfRCR ipWA== 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 lr2-20020a170906fb8200b0098e48ad11e8si16639235ejb.902.2023.09.30.15.31.56; Sat, 30 Sep 2023 15:31:56 -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 AE07968CD7E; Sun, 1 Oct 2023 01:31:02 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BB42168CD54 for ; Sun, 1 Oct 2023 01:30:58 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 167A520005 for ; Sat, 30 Sep 2023 22:30:57 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 1 Oct 2023 00:30:43 +0200 Message-Id: <20230930223046.22896-12-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230930223046.22896-1-michael@niedermayer.cc> References: <20230930223046.22896-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 12/15] avformat/westwood_vqa: Do not leave vqfl_chunk_size invalid 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: rUzoUwt1q3gG Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int' Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_WSVQA_fuzzer-4613908817903616 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/westwood_vqa.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/westwood_vqa.c b/libavformat/westwood_vqa.c index e3d2e2668c4..18948d14ccc 100644 --- a/libavformat/westwood_vqa.c +++ b/libavformat/westwood_vqa.c @@ -194,8 +194,10 @@ static int wsvqa_read_packet(AVFormatContext *s, * includes a whole frame as expected. */ wsvqa->vqfl_chunk_pos = avio_tell(pb); wsvqa->vqfl_chunk_size = (int)(chunk_size); - if (wsvqa->vqfl_chunk_size < 0 || wsvqa->vqfl_chunk_size > 3 * (1 << 20)) + if (wsvqa->vqfl_chunk_size < 0 || wsvqa->vqfl_chunk_size > 3 * (1 << 20)) { + wsvqa->vqfl_chunk_size = 0; return AVERROR_INVALIDDATA; + } /* We need a big seekback buffer because there can be SNxx, VIEW and ZBUF * chunks (<512 KiB total) in the stream before we read VQFR (<256 KiB) and * seek back here. */