From patchwork Sun Aug 4 20:53:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 50892 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1f5a:b0:489:2eb3:e4c4 with SMTP id jm26csp1050580vqb; Sun, 4 Aug 2024 13:53:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVju0HRjTNgP/3uPydPk4mbQVWnS1dNes9For6670pxC+Ki8UyWQzaVIGTIGAmPGpGlqkeo48M07E2rpGjKsixJ+n20jGOTUVyE3Q== X-Google-Smtp-Source: AGHT+IHBlmAL4fT8i3Uet8zLv2dMycN1UY9E9Vr8OlRY53YVwMlw59KwqluTrnazoAc0IxeRoHZN X-Received: by 2002:a05:6402:185:b0:5a2:3df7:bb6a with SMTP id 4fb4d7f45d1cf-5b7f56fae19mr8663883a12.31.1722804812786; Sun, 04 Aug 2024 13:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722804812; cv=none; d=google.com; s=arc-20160816; b=uyu2qZuheWt3PR2zn8mkP3hKCq2Q3KeINnpKxrLS/Q2nWfEcgV35/UVhnFBo/0yVJF Mfaa5/tkoEFIxLTVkHBJ3hIC934HcQrqtVh8Ia83yTTIU9D+g9CrWZoQ7OlcNNIh/6Ge XnIrKjxZZBAyHNZ6KzyNIj+k8PDhwvOofBaX353LZOXHKFsmZxd7ZsvvsRm2PQ24J7a7 pPXsIz/u3rMW3GgHOb8OhHM668Cvipr/7uPkf9Wvbb5/hcdPoAgiWgSAkCbba/kKh5qI EPzWNG5J4DS9uotkaOo3nXcGSgMCduqEEph0xxlZijRtmU6GxKZW92qblOZxMKK3oJmv 9MEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=PxU7YMifbCgBSwBF2Dmz87kciNnyaoDXPCynZcbj7lQ=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=qfytKm7MD8Q1O7FubDZ5H0pkkxhK7xImgDzreK0ljApy7BWsNzd2dEMZMikng4OYyR xmsMLUw1LY+NrBWjxpxMo8H4bUfJ7teUIfDRJpfA5vA77hZtmqIoL0VanE8Tm6+a1aJT vKJN5QGo+LYcK1SYt0dXTW7RsBHHVJW197rxjjofBnFCPVKU2kOSmCjLm5KA0mnquKAi ee5AbtHvUnG26HAdJEljmn3JIIkLsGDpdVMytuQotXQBKyWb7y/0VBOTKeHx2gbVQvj7 p9c+lUYrMN2bf2+g+y809MCzXBRxToT+Dg2P3fOrx/Z+vyd7znXAEnvwAl2JQq29zUsV R8Nw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=QI5pa4R2; 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 4fb4d7f45d1cf-5b83c812537si3628428a12.602.2024.08.04.13.53.32; Sun, 04 Aug 2024 13:53:32 -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; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b=QI5pa4R2; 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 6A2F968D957; Sun, 4 Aug 2024 23:53:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F1B9868CFC0 for ; Sun, 4 Aug 2024 23:53:11 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 4193FE0003 for ; Sun, 4 Aug 2024 20:53:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1722804791; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lfJxWwyKIGLLaplgcnL1qEkGNZofDFE7hHth5RrTNB0=; b=QI5pa4R2I/qefcumwYEzcIgx1kHJ94uDiMeMbFDkgCrTapb5qvwJKBcczW72RxN4QafBDF 09eaE49Mdddl/8OhwUu2n0TcwtPff7s6s7COmnnxcAoH8KtCgEr1fxddDHnSSpI1moNZiu xrrPx9couUs5pvbqiPkrjjkjaZlGc901q498kruxN1Aas8kVmsKuQCX8bnRWQpJA53KE+2 2EMfbRilkbAF6Gqwr5HK/0gD0+5foqJTF7oO3KQbm9MxMg0PlKKCGX1dR5qICcgaZPpbuL 1yq8i6cQelQiZAZtcPOfqa+F++37nJniNe/yZviJHAHUt1tG2HYprxhUf6LZQA== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 4 Aug 2024 22:53:03 +0200 Message-ID: <20240804205309.1978196-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240804205309.1978196-1-michael@niedermayer.cc> References: <20240804205309.1978196-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 2/8] avformat/mpeg: Check an avio_read() for failure 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: YpLz2FJmNsoI Fixes: use-of-uninitialized-value Fixes: 70849/clusterfuzz-testcase-minimized-ffmpeg_dem_MPEGPS_fuzzer-4684401009557504 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/mpeg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index c3dff3e4ea2..262e398fa5e 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -566,7 +566,9 @@ redo: static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 }; unsigned char buf[8]; - avio_read(s->pb, buf, 8); + ret = avio_read(s->pb, buf, 8); + if (ret < 0) + return ret; avio_seek(s->pb, -8, SEEK_CUR); if (!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1)) codec_id = AV_CODEC_ID_CAVS;