From patchwork Thu Sep 12 23:33:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 51557 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c541:0:b0:48e:c0f8:d0de with SMTP id f1csp717vqr; Thu, 12 Sep 2024 16:34:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXQM6d1/PJ2zgSYJzlq2b+dJImKtO1nRtRF4bKOCICo21S4g4QHS7BlGPEVXqBJ4wou5qnmC9gdDjuhOntUGyG3@gmail.com X-Google-Smtp-Source: AGHT+IGKFGJ3Hgf0z9FtLAVuIB1+OykJvg3Rvbz1ixg+BiSHPHr4NAfePpQmsbDbFTYAS//9wHHp X-Received: by 2002:a05:6512:6d1:b0:535:6795:301a with SMTP id 2adb3069b0e04-53678feb14emr2611517e87.47.1726184074269; Thu, 12 Sep 2024 16:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1726184074; cv=none; d=google.com; s=arc-20240605; b=UxvgCNQK6jiw0cv+N5Kh6hCHOEcJqJF6X6VJynPKgv4R7kOu36TUgstFV8tdLYfcJS Jw7IiltJPEqnHkT5zPSH7Ro7I5lqwhGXy4YT4r0PD+I8vv7ZR3/gSXUuEdzrKkYgooUD x5NJjCeO8J3hvfcNbEPGVjWjIrk6GjrBpsVsd/EZT6ZTsuCar4N9+tl+SHTV4+2kQtFN HHVyIbmO3DIXuxro0RNSO/jEcM/ejhaRxNYKI5newTWxFiGpQnPPYa+7wTOx+07cQCoV r816H8DFGedh39jL8pFQJvKu3jWW+4Ol8nHaaXKXWQpBDgiGkX1PLgJJISwQCxeGh/XX ew5Q== 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=VYfc0LXiBn2pHEQEJuru4Z0wuZ1vhitfmZW0AnIhDI0=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=dcjOQM4J3U6/e1HGZ0v7KHQusfYiQAv0GEvm7deDVU0j5E1unx5IeL/TZVEEawKRPw /5rFTHwPYuB6YSWGq5ua/qsh/CEKW9iuVY8YEmb6vqRWjYvBdlcNg01CL2iTc00mhZqU ppxfhCJ5dlNBOb4kecccyyK0AhhHGvYuXXePJrvFF/LcOXXyg6ip7MSJCC2xNQ7h4CJf J5yPXTc49Z3jNp8Za+KBhVsXyNeq0vUCw500X331EinvVAXTbvBOSGNZIB7qC4CC0jHu 5M7aENOnYuNjL3OmcwLCb60yBDmkda1VtFDnzVPNTNbvR7bTrbz8o174PmS9zWkralIl wfwQ==; 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=MeIfmIPP; 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-5365f866fe9si4225733e87.3.2024.09.12.16.34.33; Thu, 12 Sep 2024 16:34:34 -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=MeIfmIPP; 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 ED4CC68DDA2; Fri, 13 Sep 2024 02:33:51 +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 EAED068DC7D for ; Fri, 13 Sep 2024 02:33:42 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 51ED4FF803 for ; Thu, 12 Sep 2024 23:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1726184022; 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=RaKpQGy/d9tEobFsYG72jjDgSNq5dg6qVFNASDhvvyY=; b=MeIfmIPPdTNhyp9wlhIBQ5ic1FttM6TM1CnUeQf0oFQfNoW8u+rebKPlAQq+MjFpHQIxxm cOVkLug7AeU+tnKcauygC79JmuQ6dAt+fEuyT9wlhjbeIRXqFQwcwpeSdwoHOFPZCGPpBA YiwiUFITQi7Os8sdxXDDsQ9jYFrHMrJyGZ1BRVzOG7t3pgpnKvkRAVjspTif8MU0vKk5Nq dzoHq2tsU/X0veLs4ex9TkimCebh6UgMdkfJTlxiCFDt2BGRjXjAyPeogoBuVfjg2OQj41 3mphjKu/NADUD0p0CVSmwJRG35gqOxsA0r6bNQiej3XKugZM5dROahT0DRA9xg== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 13 Sep 2024 01:33:35 +0200 Message-ID: <20240912233337.2444412-5-michael@niedermayer.cc> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240912233337.2444412-1-michael@niedermayer.cc> References: <20240912233337.2444412-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 5/7] avformat/mxfdec: More offset_temp checks 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: aZ7GVzwRqqKo Fixes: signed integer overflow: 9223372036854775807 - -1927491430256034080 cannot be represented in type 'long' Fixes: 70607/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-5282235077951488 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/mxfdec.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 8eae9f87afa..41281c5196d 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -1924,6 +1924,11 @@ static int mxf_edit_unit_absolute_offset(MXFContext *mxf, MXFIndexTable *index_t return mxf_absolute_bodysid_offset(mxf, index_table->body_sid, offset_temp, offset_out, partition_out); } else { /* EditUnitByteCount == 0 for VBR indexes, which is fine since they use explicit StreamOffsets */ + if (s->edit_unit_byte_count && s->index_duration > INT64_MAX / s->edit_unit_byte_count || + s->edit_unit_byte_count * s->index_duration > INT64_MAX - offset_temp + ) + return AVERROR_INVALIDDATA; + offset_temp += s->edit_unit_byte_count * s->index_duration; } }