From patchwork Tue Apr 27 19:21:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 27441 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6109:0:0:0:0:0 with SMTP id v9csp1238678iob; Tue, 27 Apr 2021 12:22:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwh4yfN1PiIQwm3LBAtbto471t5RoH2XJeg/Dw2nEYsqUguQytpL34L/F94eSjvBSzeJn4B X-Received: by 2002:a17:906:7189:: with SMTP id h9mr17882973ejk.71.1619551369569; Tue, 27 Apr 2021 12:22:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619551369; cv=none; d=google.com; s=arc-20160816; b=KHq6EuarEsHjYpmVuPMapsXVo7rQEte2pyhwFwNuSwKbTsm10fWxkXN0VoIwxlUlf1 5Gf0xXjyZ0CxO5eyx2GI5VgZit+4yqFVqlvRqvR03NmQ3iHF8wo2rk+LmEbCqJK0RFIq FX3cXyvpeeop+KZSXbrZ0UXOj+P/AC8WcAQK2a0BK23qPOgxiYZiNPl+C+/RnScLI9D5 MmHLLBIWRnRcyKKvdy2yHu167SHo22FDlZQMHshINQgwxbM/Cen36b6Y3pFcQsrAzXui 4KSxkXlofeqdMKFB4NcBoi6ZB3nJxl/us+N8or/eUP2/hQ+UpLvaMSFmXRyszbE6j8Pn 415Q== 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=fC2O7jpQqDndo6KzpN7B04QWO9T53fHfmeH+bWFbbIo=; b=1AL8ZUPnFPg/gBPvPleptNEfh+sl4vuuxuWl49b3mmO4EX2UjhbtnUvHPvxKxsvjp5 LUIejo2UC0cPEP2UDRuLVdX3BUrR6pRwPScfemoiKNnFmNS3QXue6ctwPGF69MLf4pOE loHjj7mKJ/2mXDudcTSmxAQXddmEA4gXd81wmNtJknJFL5ZapXhnBJcCSVAXrs/iN4Q9 ibeeZ6ORxpUU0SmW1v0dJJys+yXLdgTgDsH/wQjLTIQCXhtn21GTexzPIppV62YXCXGa S67g06z8lr4FvnBYnmL8Szbm/5m3Ey7RaznyFOZnuUBoA9klZzQf703Rx/+U6Kt0e8/z LyZw== 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 x9si804663eje.242.2021.04.27.12.22.48; Tue, 27 Apr 2021 12:22:49 -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 A5825689BC2; Tue, 27 Apr 2021 22:22:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe05-1.mx.upcmail.net (vie01a-dmta-pe05-1.mx.upcmail.net [84.116.36.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2E210689969 for ; Tue, 27 Apr 2021 22:22:36 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1lbTI4-00CvCh-09 for ffmpeg-devel@ffmpeg.org; Tue, 27 Apr 2021 21:22:36 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id bTH6lEuQSljeHbTH6lFofn; Tue, 27 Apr 2021 21:21:36 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.3 cv=BoHjPrf5 c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=Nt2_40D_sxpb0CkXUDoA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=UDnyf2zBuKT2w-IlGP_r:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 27 Apr 2021 21:21:33 +0200 Message-Id: <20210427192135.17286-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210427192135.17286-1-michael@niedermayer.cc> References: <20210427192135.17286-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfGTdjo5T48xJeOVTt/aK4+mcWMifwLzX2ZOzvKEUO/ITF/2zvhDuslxblLVbzIIPZU0a+fQJM0RGFMvLAq2Lv9XrMKF4+NG86T82GI4PXHp7Y58oMUvW Kj7eUfkxZXnsaMOlQm0G40Qs1bKb7EkQlX6eovu70xNEJLDyiqBeJ80P Subject: [FFmpeg-devel] [PATCH 2/4] avformat/rpl: Use 64bit in bitrate computation and check it 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: xbtcszWE00fz Fixes: signed integer overflow: 777777776 * 4 cannot be represented in type 'int' Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_RPL_fuzzer-6726188921913344 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/rpl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/rpl.c b/libavformat/rpl.c index b98488c7b1..558e5718ba 100644 --- a/libavformat/rpl.c +++ b/libavformat/rpl.c @@ -207,8 +207,10 @@ static int rpl_read_header(AVFormatContext *s) ast->codecpar->bits_per_coded_sample = 4; ast->codecpar->bit_rate = ast->codecpar->sample_rate * - ast->codecpar->bits_per_coded_sample * - ast->codecpar->channels; + (int64_t)ast->codecpar->bits_per_coded_sample; + if (ast->codecpar->bit_rate > INT64_MAX / ast->codecpar->channels) + return AVERROR_INVALIDDATA; + ast->codecpar->bit_rate *= ast->codecpar->channels; ast->codecpar->codec_id = AV_CODEC_ID_NONE; switch (audio_format) {