From patchwork Tue Aug 6 22:18:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 50919 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d7b2:0:b0:489:2eb3:e4c4 with SMTP id dc18csp22560vqb; Tue, 6 Aug 2024 15:19:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVWjODGdamREnkPtKb1yvgCEkvWI84tEaItSWWy0aC4FMJbuvrckzyCH1VyNRC2/AUgitF/SrjtUA/nZ/P7lAfshNtMxrg8b6pslQ== X-Google-Smtp-Source: AGHT+IG++uWfh6QztwpozBEw35WUPX6tMIzeK5B3UFW+mNqTPrwHvwDNeF652GbBe3KvN/KaEpcB X-Received: by 2002:a17:907:3d8c:b0:a7a:b643:654b with SMTP id a640c23a62f3a-a7dc507105dmr1292094466b.50.1722982792461; Tue, 06 Aug 2024 15:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722982792; cv=none; d=google.com; s=arc-20160816; b=cfq+rTc3gVjybrhDwZjry6ceQ8lyaQa76qlvX6981MaK1OObn4qt3gov/ye9tL4esQ I2ZO7HYezHUJJYFN6pvpWZSIUmNxj9tSycIgP921hCqpomGEuf4RY19Bovsc32YMtC2Z dUHe/3X5dtQhstpruOrkw1lZ6UXSxorZZqrb3QE7Gajdl7G2IlzWktjjLBPf1ZDPoOB6 KXjwozX21eZM51oG9UpFixuaa+trHZTwEmn7JUhuxBgT7+BSuoLhdAEqZAdX1zsS12TP 4UlgadLSI46rwyuj52dpMFTU7T63j4TY0fY8n84wfej7JKh8y7OXYIDe3b5blX6aVC5T 9HJA== 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=7ti4OFHjpl3zegjRhxJuMEgohGIVnnYHquaQVmL7S4U=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=aDDU1fyQJkCys6AdRO5RcYaxROi+UJoRErRcAWRpwgN8OKHRWvpTT2IWzkBvTmKaJo zetxr15JkAqQaA3gVgpeSKvRnDggGBQl5XklForcmtC9IpmVcQAyaKEzftxf+X1CPKB6 OQR0gvg4yCz6mPZ4/UyS61AQnBD54ls8TFj3RlnOg5mb4EHG92gW2Q0vEcM6tuedTAQz ++wVWAmjWOH6i3/tZNdYBKihAjXQGZq8rARYUk2kc6rEGrLAnEL5FuZCl6gNMfM2XeJQ MB2yOgWpQKTqbuY88g5UCNXQmR9G94d1X8jeVgLrzbJJSYRJbpFRQF6h97FyVgkd4dzP UCYg==; 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=IBgY2auP; 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 a640c23a62f3a-a7dc9ebb810si595894866b.630.2024.08.06.15.19.52; Tue, 06 Aug 2024 15:19:52 -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=IBgY2auP; 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 ADD1168DAC4; Wed, 7 Aug 2024 01:19:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 29D9B68DAA9 for ; Wed, 7 Aug 2024 01:19:00 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 89D9F1BF203 for ; Tue, 6 Aug 2024 22:18:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1722982739; 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=XicLMO/gHxgBJh5rA7T9989MylxD3ALhORBq2thG56Y=; b=IBgY2auPVSSmE0qjF4VFwUIW7WxpB8Ihl4AuJB5TYDODqUZegtAsn4yPc80YRCQEQGxkni DYHgKXz6X6oHCYIBtPbm1136jgEpa9cxAUPXZ2OkREJZYiotAvgs4bz9srZ8r5txvb7Rnp LRrgXgVTuo5laEXcP1lUNQpD0TzCmtO8S8aaRHg9iD+Ne7qXWXtEN98a6vGoMThccxy3DF FTZ1+zhMnYaggkSASNJg2TgnwbqG5Mq2Ar+XB3+wel/QPE0fgyc+M2feVBDIfITHGst/mE hjKaPqhGZzuwyUOaCFfh2DhfTMZ1KUpef+Z1/e75drDJAzxQdlgSWmu+TUT3rw== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 7 Aug 2024 00:18:53 +0200 Message-ID: <20240806221853.959177-6-michael@niedermayer.cc> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806221853.959177-1-michael@niedermayer.cc> References: <20240806221853.959177-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 6/6] avformat/wtvdec: Check length of read mpeg2_descriptor 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: b1kJU6sLaTxj Fixes: Use of uninitialized value Fixes: 70900/clusterfuzz-testcase-minimized-ffmpeg_dem_WTV_fuzzer-6286909377150976 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/wtvdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c index 1a6c4c33481..730c7fca783 100644 --- a/libavformat/wtvdec.c +++ b/libavformat/wtvdec.c @@ -846,7 +846,8 @@ static int parse_chunks(AVFormatContext *s, int mode, int64_t seekts, int *len_p } buf_size = FFMIN(len - consumed, sizeof(buf)); - avio_read(pb, buf, buf_size); + if (avio_read(pb, buf, buf_size) != buf_size) + return AVERROR_INVALIDDATA; consumed += buf_size; ff_parse_mpeg2_descriptor(s, st, 0, &pbuf, buf + buf_size, NULL, 0, 0, NULL); }