From patchwork Sat Sep 30 22:30:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44074 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1204:b0:15d:8365:d4b8 with SMTP id v4csp599367pzf; Sat, 30 Sep 2023 15:32:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/Ws/XbJLXXyq/h/4yIV59rGBJdJz8RNHetRCI1nx47tx89MhWCopgbny6SnTLs38/+4tC X-Received: by 2002:a05:6402:2694:b0:530:dd97:fe78 with SMTP id w20-20020a056402269400b00530dd97fe78mr9264055edd.7.1696113176067; Sat, 30 Sep 2023 15:32:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696113176; cv=none; d=google.com; s=arc-20160816; b=mTzV+XHzMupgIU0VoMHuaXef+HXVxu7LqZVuCdfBHeVjvVQGC8HjqK5y6PjnzkFal3 0T1NN+klFiexExyc3UvfwvpEFtNUoCgHwyWLzLnKfyFyK4UbQo4VMUaqMErPr82moH+O YP1azM4SeR+ODGpbe0Pv5hmtmQ4+TGIfd+/HwTjagTR6h1rEEdRNNErHyNOnQy6HeudR /BzM/K7d4viKqhFKQf1S1SVeoEoYRwhzWms0IbVTJVZVHpJgk1TvsjZpH7NW7F2x9viQ 4eDQRSjrY4jdDw0+3WLthbYIKg8yt82ukXaVV7JDpGbJyn5UkSqqwTYuSv9PVZmbuq6+ dLsQ== 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=HX59INerhoRtchTXeUXjgAz7Hgll4wLYKbtnfUz79PQ=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=xiUpOOGy4eskcmPaH44E3dJ9E16DH+hy2jS6snqosxoOSJ9ZuybTI0pIaDuX0Wrzyf X7sTwkBHf72UN4xY8g5Pfn5f5APdjLPgQOd4cOdcTJtOdtsra7xTpyNSysnyi25Tixq1 My89Z3uvXfSnZ/F6ae3C8bQQ0TGfZ8hs2U5We26s2Mt2ZpolYVYvxJfrVY92jNWX2oKO EtF3laCr2uuh1Gsz0+Rq+Ec2l+XjYiLpGDTVy+WodNCT7hGWAjUZOV3e5vIBNQF6yAWX GWsxG5is608jDqg6XL4vylsM40KSsf840hkrB8uy4ueUo4lv37whmQjM27dBfDVAZGx+ VrFA== 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 e6-20020a056402148600b00530facdd601si12123062edv.342.2023.09.30.15.32.55; Sat, 30 Sep 2023 15:32: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 7684768CDA1; Sun, 1 Oct 2023 01:31:09 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E619968CD72 for ; Sun, 1 Oct 2023 01:30:56 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 501DAC0004 for ; Sat, 30 Sep 2023 22:30:56 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 1 Oct 2023 00:30:41 +0200 Message-Id: <20230930223046.22896-10-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 10/15] avformat/wavdec: Check left avio_tell for overflow 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: mIlrBtxJ3tEE Fixes: signed integer overflow: 155 + 9223372036854775655 cannot be represented in type 'long' Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-5364032278495232 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/wavdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index 97e69ab2ee4..b145e980414 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -767,6 +767,8 @@ smv_out: goto smv_retry; return AVERROR_EOF; } + if (INT64_MAX - left < avio_tell(s->pb)) + return AVERROR_INVALIDDATA; wav->data_end = avio_tell(s->pb) + left; }