From patchwork Tue Aug 6 22:18:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 50915 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:d7b2:0:b0:489:2eb3:e4c4 with SMTP id dc18csp22316vqb; Tue, 6 Aug 2024 15:19:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUqz1vtMRsNE9QgBhwtKKNPtiIZ+sXdxEa4DNWZsfdMljyOaDyBX0PjtmlT++yOLsI4oVxguGy+xJQXILEEHRCFd9aVLpM2+LY61Q== X-Google-Smtp-Source: AGHT+IEsqSaqC9FX2pgtvY4KWkgockwM++ANw9SF29lSlZznyhcJtDSLn5l3GZsEKRdL6nsnEr/K X-Received: by 2002:a05:6512:1094:b0:530:b76c:65df with SMTP id 2adb3069b0e04-530bb388cd9mr11408414e87.35.1722982760851; Tue, 06 Aug 2024 15:19:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722982760; cv=none; d=google.com; s=arc-20160816; b=UzTIlrQ3r0SAxMBsBDVRbnP/6xOdAyrtZ6ucy5tiD3WsOzC5ogpYgVUwcQxLslzBZy cYSk2URVJDfmtWxS3BherEKxHQqwMEoqU9FdhEtCZm92DV/1XZYkTzCT9ImUXOmonY0j BbKT2YiG5ULF44e00kXz3aM9QpghTkkG4rkgGU5F1nbflG6+Y/tVQtt+nZoGKkDD8wEV 0i9rgR5CDITM1g5SiesIPPEI1tFpVvbRBsb+USXSiCCi0jOKP4VqH2KENu5jEy6KoNv7 ItlcRyNv4lBC/DYXS6GDJp/SZRtII73kWP4UUQtnN3K5D9WBz4VVELsljIVSBRhrP9Yi 4NlQ== 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=HWtLj8z0PAZAP/8urJ8E5Oxig0vRfS+NWYKfvcixtdo=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=DMWlRL9j7f9rPIqiEYzje6e5yLB87DLc47wCL1RosnJTNiPd+gNO23/FEmtpuPyxA2 EivyaOFKrNgN+rqo3aN2C1y/mAAv3xW83FxqdMEhXHkt9TLjU3ShDQ5v5uEIMjcsZqRz iYZxpFsHUYvUAjy5m8mL7Zm2Ll+hxSbyQkmcNMX/N25tVVX+Jl2zKcqINJkTtgrAj4pn y+lC2W/saw4MchTuJeOVmr30qy6vxlhdUTF3149sJ5E4pEpIxg0C+46+ojhPcbAXtAkc daqsuaS+7MHZcGhikVsrp3WQr6ihuxM9DZHB6s4ReRrfslGeExCbj3xzXcPZ5m0LJg4X VMzQ==; 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=M8Di+QV8; 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 2adb3069b0e04-530de435ae7si9080e87.57.2024.08.06.15.19.16; Tue, 06 Aug 2024 15:19:20 -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=M8Di+QV8; 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 024CC68DAB0; Wed, 7 Aug 2024 01:19:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 12B0F68D9D2 for ; Wed, 7 Aug 2024 01:18:56 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 525E1240003 for ; Tue, 6 Aug 2024 22:18:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1722982735; 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=hePN5FbddE7mTLoehr9FVC5VtD/YwB3vuP50fNY038E=; b=M8Di+QV8x5tlOIGGbp/zaAJfenB8+c/f1oPOp+lmMGDbrvFbUTfUgOzhXk3vQNl6/7Pcxw NijlSQNRA+8LzZlmYKQHctqlLKXT1JnWJgMcKg55ak8XLlhaXeLe6i0TM3kMfuB8bOD7jv 9AdNH/WZkBxsMPvF8jqdRTVAL+HlOuJPcv2vOrQ+3/E9UnMTzSujZJXbjvXH00nC+NkdmK AjCagKkjrwp/JVycOoz1Zsi8rSnz0FCTt5lZsMvYuOk34tXlawZiF/OCQXfq7oNGlzX5RV W5bUQG7X1HC1vilFBYh+eRnBjFMKSp6/TZ8hapgcrSnA95DawSa24i2rzobShQ== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Wed, 7 Aug 2024 00:18:49 +0200 Message-ID: <20240806221853.959177-2-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 2/6] avformat/av1dec: Check bits left before get_leb128() 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: syl/MQzjbyQq Fixes: use of uninitialized value Fixes: 70872/clusterfuzz-testcase-minimized-ffmpeg_dem_OBU_fuzzer-6005782487826432 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/av1dec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/av1dec.c b/libavformat/av1dec.c index 3363003b181..a5b620a0abf 100644 --- a/libavformat/av1dec.c +++ b/libavformat/av1dec.c @@ -326,6 +326,9 @@ static int read_obu_with_size(const uint8_t *buf, int buf_size, int64_t *obu_siz skip_bits(&gb, 3); // extension_header_reserved_3bits } + if (get_bits_left(&gb) < 8) + return AVERROR_INVALIDDATA; + *obu_size = get_leb128(&gb); if (*obu_size > INT_MAX) return AVERROR_INVALIDDATA;