From patchwork Mon Sep 23 21:32:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 51775 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d154:0:b0:48e:c0f8:d0de with SMTP id bt20csp2734900vqb; Mon, 23 Sep 2024 14:33:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUIXwZhe9/CfXtPNdUPaAY3ynQgwhY8k+DGwzZo70yzU1xMAPg05jCfG12bXt+eSDDxW7+fhJ+148N2f5p0vaAW@gmail.com X-Google-Smtp-Source: AGHT+IFk/O2mY1mSXfk5JFSU7EJEkWR9ab96F+TXll0/UcuBxRZuHZrvs9wFkyiqo+Ctu91eSp6y X-Received: by 2002:a2e:be20:0:b0:2f7:5915:436e with SMTP id 38308e7fff4ca-2f7cc3572a2mr66309141fa.2.1727127220689; Mon, 23 Sep 2024 14:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727127220; cv=none; d=google.com; s=arc-20240605; b=MshlaS+sEXS1su+jnzgMKumpw6KGW/VPnmVRWt1u0G5U3UHKuDiyqyieL0hgXDy4rL Ld0wNgb7ey7BiY5QEFCq19DH6NtyqrYTRu/5bUgHPoboNnUMMyO8Xxyxr7/40OQVVRc5 FGQvtLzOvBAB8LcrQEDipXnpVUSC+P+IlVcM0ZGZnkz8W+9v2TieMpo828RF3xqDgqQt ETPbMieOAWf93OQIAQmlTzTNYInfKJIkLxUxqtlHGuV6NKSCprbvvpB80e5CHanzQ7Fa iAjg7NmEgsRmPPUqhiBMvLecJcCT/O499CqgWpgm5w2fWdIT9/WKgub1rKEd6Y8Pdsqu 1FZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=SJIFQp8fZV8qwRzEn8L6u6gCx4sjlkByYEQvGs2DT/M=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=YolvuTtQr4j7Tvk2GctNKcvGP/ayyoKWcRK9vNEmWbGpILoXMhhljJo2Eg8SFxrAGY Q0110iQEBo2+lWo7DZRgCZwlsjq8XneWoMmafMKpZ0SWMQfSGl7HuNcx/XY6L7oDZTPS EH4TVLVRrYSjsuMtkFP7zS2IWDwFT2L5G6iTO0tfiOL8b9vcytRxVian8UdqIh5dndgg P4gfPmhSO8fA61ME+YdcZFlAfheodkzXWr76rO2KW2VIy6nu18vXFJ4aFYc79VRdRkzb ZmT4uuVZv1DOBExk4f2TY7vsd3vOqaq8W1X7NtgFhHzlyZ0FWOurUEaKxUcFaSvv7FXy /Rcg==; 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="i/SMyy1z"; 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 38308e7fff4ca-2f8d282f08csi420371fa.9.2024.09.23.14.33.40; Mon, 23 Sep 2024 14:33:40 -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="i/SMyy1z"; 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 A800968DB57; Tue, 24 Sep 2024 00:33:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C778668DAC6 for ; Tue, 24 Sep 2024 00:32:55 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 1F117FF802 for ; Mon, 23 Sep 2024 21:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1727127175; 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=d5VQIdVEi8DRzZJqTPTwulyx/igsBFeyQ5M7Mq5G4Gk=; b=i/SMyy1zobaZQ+R/SJof0B3KY8F1BrOruosnBJ9JJQZQ5HXIb75zPO2l8NOD4WGBPxh5uJ hPARQ4nroCz3edxQ4uc0h2W7kCD47DXjFJf0C13g4V6oSSBEOYvNdXkhFuiHUXgZvrXglR OOq8BAGJ8LGtamLXFYOtsbzXGx8qahLK8Nznl/hXvRehM26uIeG8gHEm1G/AtHBCGABG7s Y4WfWkNZn6euaBaUVzLJA64WAJnjxPR71Y3sWMr/Miq7HktzIfUVjqsYfYJ0lE8ycYfEAF y32WDfkttz5amO0O7C/1lRBpc8svt8FLhQsh02/3GGLvOxwqdYjH3FlRYN4JTg== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 23 Sep 2024 23:32:47 +0200 Message-ID: <20240923213249.3256534-5-michael@niedermayer.cc> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20240923213249.3256534-1-michael@niedermayer.cc> References: <20240923213249.3256534-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 5/7] avformat/qcp: Check for read failure in header 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: WtuY8O5sZJpj Fixes: Use of uninitialized value Fixes: 71551/clusterfuzz-testcase-minimized-ffmpeg_dem_QCP_fuzzer-4647386712965120 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/qcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/qcp.c b/libavformat/qcp.c index fdf18618d23..13a479a11e6 100644 --- a/libavformat/qcp.c +++ b/libavformat/qcp.c @@ -105,7 +105,8 @@ static int qcp_read_header(AVFormatContext *s) st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_MONO; - avio_read(pb, buf, 16); + if (avio_read(pb, buf, 16) != 16) + return AVERROR_INVALIDDATA; if (is_qcelp_13k_guid(buf)) { st->codecpar->codec_id = AV_CODEC_ID_QCELP; } else if (!memcmp(buf, guid_evrc, 16)) {