From patchwork Sat Sep 30 22:30:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44067 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1204:b0:15d:8365:d4b8 with SMTP id v4csp598964pzf; Sat, 30 Sep 2023 15:31:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwh6GJRTW8pBztHW0EiusWlMS3upUuw8AcslpFm0Hb+ppx7tFQdrj2xDk0UQtn413n3jfO X-Received: by 2002:a17:906:cc15:b0:9ad:a86b:2337 with SMTP id ml21-20020a170906cc1500b009ada86b2337mr7167170ejb.23.1696113108287; Sat, 30 Sep 2023 15:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696113108; cv=none; d=google.com; s=arc-20160816; b=AS2dP9oIHO8d8B742RfuiWXM6xwWjKiuvppjKPGI3OtLEAcPrYYF4eeBJBoN11jVIl VWbDWlqFJ59xa+GLxIUwhlOq5rPq+y+cCY8qc1U59wUOo7crmrq73nu1WNa9cQseyHYi mxp44JSsDOwDtT4tR6pnOj1s+ebbUQsLOsq3SRYNB3ckeVmXk4ByLAM3aLiEkMhWAqAS cMXpM5cvPIR0OuUwR+sef4Y5dJCrtNCUwOJpjdp0yBt49m/Rxf1vFoitb+RvV4n/CZIF KbtrOZU4Bv2oXuCYdw2EagD8TkX1VaqDNGEoPNx9pagX4E0EHzwG3Xe4naVpDNTOk7Cv HFQw== 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=V1QWe2aoV00NHOUalDzGD8mT+ewq3wRh+RmIuJWPTKE=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=NcFLQNCiFEW+KwLPbnrC3BQ26A09wTrPd0B3lCO2arM9i9ci/Kc957b/YCnw/Jjohu delKUv59jegyj1mHRpylcrnZTU8Bb+Ql9pYzcW+vmFZz/9ukgUhTeZY7kcFAjvV5/s2x hmjsfJwKyehf0zYRrqksrnhbQJH7TPZ2VbBpacLzh1O2Rp4ekWjRa1P9j2TpKbwSkHLo YuOOI+5hQYdiOcDGveJA/BRUFa4IO1P9J28MXdIyTeNa76TR3rkF/KbDxlnYWhJwZngo 2QqbgvCOaH+RqhpQ666CBNXi3wX8YWaC+gG/e1FpCFYTdynRzZJxx4uOLahaC4tUwjGs TPCw== 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 o26-20020a170906359a00b0099e0daaa531si18022229ejb.556.2023.09.30.15.31.47; Sat, 30 Sep 2023 15:31:48 -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 B55BB68CD58; Sun, 1 Oct 2023 01:31:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 17A5268CD55 for ; Sun, 1 Oct 2023 01:30:53 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 74D4C20002 for ; Sat, 30 Sep 2023 22:30:52 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 1 Oct 2023 00:30:37 +0200 Message-Id: <20230930223046.22896-6-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230930223046.22896-1-michael@niedermayer.cc> References: <20230930223046.22896-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 06/15] avformat/rpl: Check for number_of_chunks 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: MPtoZUKuB00b Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int32_t' (aka 'int') Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_RPL_fuzzer-6086131095830528 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/rpl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/rpl.c b/libavformat/rpl.c index 3ef6fda3862..eae0da891bc 100644 --- a/libavformat/rpl.c +++ b/libavformat/rpl.c @@ -268,6 +268,9 @@ static int rpl_read_header(AVFormatContext *s) "Video stream will be broken!\n", av_fourcc2str(vst->codecpar->codec_tag)); number_of_chunks = read_line_and_int(pb, &error); // number of chunks in the file + if (number_of_chunks == INT_MAX) + return AVERROR_INVALIDDATA; + // The number in the header is actually the index of the last chunk. number_of_chunks++;