From patchwork Sun Sep 10 01:09:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 43672 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4e27:b0:149:dfde:5c0a with SMTP id gk39csp1372151pzb; Sat, 9 Sep 2023 18:10:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEKpyhrc9klu26l2I4HiMEZYWE4GQbdepvJNYoSUbPZxPV0O3qoWBWL77G0Mqx0eMy+wB0h X-Received: by 2002:a2e:9b87:0:b0:2bc:c4ae:c565 with SMTP id z7-20020a2e9b87000000b002bcc4aec565mr4344721lji.28.1694308225506; Sat, 09 Sep 2023 18:10:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694308225; cv=none; d=google.com; s=arc-20160816; b=BSQ7dpVibynx8UN/t3EFSQJ/GFUe1LwAog//tgWe2C2MinXXaB/Xx2qFyRX1yIDBju b2lQbp32plFy2vEzBC66Gm/csLYyJXqijr8es1KQXSjfVImXl7a46HsAA0mVh0b2Uyi6 5LCSepseqx6Jj4vfYZQwYWHqZNmtw/qCVc78qI/Rf7PNjbwQEIV4H1QorhEJDEZUuXIK f5AvFKHfS4CRvp6Qemq+QyHTPwaMfa3jim2v+k9Xf4ya6ndvief9SlMCn47PX9E1oGeN GsbL78PADl4GDQQvfgYc7NMXz1hsOoS440qR1SltshtXoL3hYdr8MHj9e3j9oL9sjz1v qHmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=Ikdtvbe5cXusrea1juRjVZ/0ndp/YzTLzfFboim0lbo=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=TuVtjc4nN1siyjuPVwP/6dUl4uv3CIowTrAhTW2R6u4rtrurlA1o412jgdRaXGh/qk TdvvlNe7ZT3u61WHJ7I6XDFdnzP27ydkgTK/+bwRvL4Sbt22XCleWw0rRmEeevbIcT8C sR5Sgqe+qPil4cTNkZC7kA3kBHCwBCzvkbHJXbqMgXSOPAuvZbILdJlGB3UKg0wiwXPg LsZgFO8RWHc++UvMTBn0D/1lAZs1jTWRgb+yXs+SDydUf6MD4l0MCJsCco7v6D9f/Xnh BqIABSdXrNVKtagp+0VREqR4bDL9tTAMm0QCEgwNQfmwWNjF+zX2gVJN6OC1XhNLed+w HmGA== ARC-Authentication-Results: i=1; mx.google.com; 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 rn28-20020a170906d93c00b009874409d1e9si3713526ejb.200.2023.09.09.18.10.25; Sat, 09 Sep 2023 18:10:25 -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; 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 06FFD68C8C8; Sun, 10 Sep 2023 04:10:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E31C968C8B5 for ; Sun, 10 Sep 2023 04:09:56 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 3FB1640004 for ; Sun, 10 Sep 2023 01:09:55 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 10 Sep 2023 03:09:52 +0200 Message-Id: <20230910010952.24389-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230910010952.24389-1-michael@niedermayer.cc> References: <20230910010952.24389-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/jpegxl_parser: Check for ctx->skip overflow 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: W+JuxXyHXeUJ Fixes: out of array access Fixes: 62113/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5025082076168192 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/jpegxl_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/jpegxl_parser.c b/libavcodec/jpegxl_parser.c index 20c8a41a89b..619a16448fa 100644 --- a/libavcodec/jpegxl_parser.c +++ b/libavcodec/jpegxl_parser.c @@ -1326,7 +1326,7 @@ static int skip_boxes(JXLParseContext *ctx, const uint8_t *buf, int buf_size) if (!size) return AVERROR_INVALIDDATA; /* invalid ISOBMFF size */ - if (size <= head_size + 4) + if (size <= head_size + 4 || size > INT_MAX - ctx->skip) return AVERROR_INVALIDDATA; ctx->skip += size;