From patchwork Tue Apr 27 19:21:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 27439 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6109:0:0:0:0:0 with SMTP id v9csp1238890iob; Tue, 27 Apr 2021 12:23:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypO77R31YocOtBoZVAjQ4QvAHgZHM3/E2279Tx+8hA3k/PCFZuqtJpVqW2tXzk/rHHNAn9 X-Received: by 2002:aa7:d5c7:: with SMTP id d7mr6424190eds.114.1619551389858; Tue, 27 Apr 2021 12:23:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619551389; cv=none; d=google.com; s=arc-20160816; b=PbaCAkfxri/bsRjucak797vpdGmY0AQgI/Kjsa12XtrhR4LcAuoASty1Ml+sWf1L/H vppf8tKNWdcrgZP2fHWPbzrJWqG9ZBpEAwGKBDWZSN1Q1TRkfwFZyI5igkfwYwS5YMor cUBII297KMBk42QGDcG7WmH+E96Fx5b9/cxHmNb0ghBx8rAIpe4jOepZYKF6h6jUtO64 C3zn/pHrfRTu4p2WqFMOvIG/3sibztk35ucrE2A5OjpK0VhsbeLXSIWsqK63W538u53V 3VqeX6OUuyYwBgJ8N2PS+eivVqCp66CQxP7ZuBCbal/21PqlGP/FUyvzfklaXq6hvlWN DwFg== 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:message-id:date:to:from:delivered-to; bh=zpqEy+pAK851BHD5wrMeGtZP6Vxpg9hmIhH/vfxgX60=; b=gXpOm2xIU7P3r9J7RQ4lgYlp4/ABC1/BV/43CYygg3cAyNXA/edq+5fddit/WHm6qr SUZbSQT9FhJkEJLwE0+0+a382Z7zBM27KSgihR5xyasHmXi8siLF/YOps8+h8KHj8GFQ IuQdcMKRtB8DtgHBwWDRCznd7oxK+cTWQZCJ4Hn7IOeTgkEpNdmF63ttgDkrEwVB5iRP K10kajWZmG7jMH1oww1ifqGzoP8YMe98bZSsWGFEkAmt74UNT4f0r2JaNB0OFz2uUaVU 41JVY1P07pIDD5dM4/mUt095dqlt11kq975x/HzwHtnqnBMB8gA3C7k/pMwOSiAJf1Fk WdVg== 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 b19si3160183edr.172.2021.04.27.12.23.09; Tue, 27 Apr 2021 12:23:09 -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 ED1BB6800D8; Tue, 27 Apr 2021 22:22:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-3.mx.upcmail.net (vie01a-dmta-pe06-3.mx.upcmail.net [84.116.36.16]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 301F2689AEE 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-pe06.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1lbTI4-009mBB-0A 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 bTH5lEuPlljeHbTH5lFofZ; 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=CCrLDihfrumrGUE05UcA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=jd6J4Gguk5HxikPWLKER:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 27 Apr 2021 21:21:32 +0200 Message-Id: <20210427192135.17286-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfGTdjo5T48xJeOVTt/aK4+mcWMifwLzX2ZOzvKEUO/ITF/2zvhDuslxblLVbzIIPZU0a+fQJM0RGFMvLAq2Lv9XrMKF4+NG86T82GI4PXHp7Y58oMUvW Kj7eUfkxZXnsaMOlQm0G40Qs1bKb7EkQlX6eovu70xNEJLDyiqBeJ80P Subject: [FFmpeg-devel] [PATCH 1/4] avformat/rmdec: Check old_format len for 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: cOz7bbYYit4y Maybe such large values could be disallowed earlier and closer to where they are set. Fixes: signed integer overflow: 538976288 * 8224 cannot be represented in type 'int' Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_RM_fuzzer-6704350354341888 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/rmdec.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c index fc3bff4859..36765b4763 100644 --- a/libavformat/rmdec.c +++ b/libavformat/rmdec.c @@ -1012,8 +1012,8 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) { RMDemuxContext *rm = s->priv_data; AVStream *st = NULL; // init to silence compiler warning - int i, len, res, seq = 1; - int64_t timestamp, pos; + int i, res, seq = 1; + int64_t timestamp, pos, len; int flags; for (;;) { @@ -1032,7 +1032,9 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) ast = st->priv_data; timestamp = AV_NOPTS_VALUE; len = !ast->audio_framesize ? RAW_PACKET_SIZE : - ast->coded_framesize * ast->sub_packet_h / 2; + ast->coded_framesize * (int64_t)ast->sub_packet_h / 2; + if (len > INT_MAX) + return AVERROR_INVALIDDATA; flags = (seq++ == 1) ? 2 : 0; pos = avio_tell(s->pb); } else { 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) { From patchwork Tue Apr 27 19:21:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 27440 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6109:0:0:0:0:0 with SMTP id v9csp1238814iob; Tue, 27 Apr 2021 12:23:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycPhntJpqxbfP4q1dWL1XX57UWS3ln8W2NZN1If+qmypAmInSOt3oITHYM8xA8gHz3kBcN X-Received: by 2002:a05:6402:5203:: with SMTP id s3mr6317489edd.360.1619551383817; Tue, 27 Apr 2021 12:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619551383; cv=none; d=google.com; s=arc-20160816; b=e6VmKboh6n30IucwuivvsMhadV+V3IL1z2KnzUMa2uDNSnCsu2spvNW9/m+vZakPW1 P1b6CTayM4rcoNn4M+trfLBY5I9O7bN6tGEr76+rvnD/MZcTxYGwYNzwCcspPXsSPSum CS9AwKjLiRyzpYdxJ/ZY/ZRUUHrQa2tyJRJ50PlWNaLWV73/2wo6aRm8n0tubMRkCohz BhlWm+4POp38pHz7YwA6K94qPHi0m6nyEn0qMKemQIyYVba2ivFJmF9GtE8sOfdKOs6x 1kM+m1CfxIBMWcSC6rqMoNSUWSiwU4e8tw+ktP4tqBbInioPMLrfnbLnsHc9C+0dvkDq LXbA== 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=t+NOmTPeFzgSwx2QdDGcm8qyledHIq66gti08dSb2eA=; b=TdYC6GpT9tUnWpKQSgtI1CK0pS3SwW/u/4yU8Ebnw+g5xtsfzS+2Swoqf5mgpwtoj0 rY1suoGoUot9Sy51KYEq0IHFL/e0+NTGq0cx3uwOVXihT6GtnYjjvun25DkAhwHANEMw erO9CWeSDFJD4786/ts6nBJd8fUMxGkU8lMRica0XmhQRmrX6by+/utoFxhngT05m/2c r8POR/cQWFsIUc2dAF7HWYIbHxFp7Elrr8JEQrnjDZUPIPHeYeuRGyxgCCBv4lyUKlC0 wIS8mg9rZWG5nFphojirDdfCEZ+TR9PgE4+9qTFXgrlOK5gvTrmLsOJlxuvQReEp0Pbg niHg== 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 t24si3363531edw.515.2021.04.27.12.23.00; Tue, 27 Apr 2021 12:23:03 -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 D4F94689F1C; Tue, 27 Apr 2021 22:22:44 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-1.mx.upcmail.net (vie01a-dmta-pe03-1.mx.upcmail.net [62.179.121.160]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2F41E689AB4 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-pe03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1lbTI4-00FPWs-0G 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 bTH6lEuQeljeHbTH6lFofr; 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=0jyFa61AvLJFixEQjbkA: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:34 +0200 Message-Id: <20210427192135.17286-3-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 3/4] avformat/sbgdec: Check for overflow in timestamp preparation 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: UoGOXH6jh7ML Fixes: signed integer overflow: 9223372036854775807 + 86400000000 cannot be represented in type 'long' Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6731040263634944 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/sbgdec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c index 83016d0c13..9530ea42a5 100644 --- a/libavformat/sbgdec.c +++ b/libavformat/sbgdec.c @@ -1291,6 +1291,10 @@ static int generate_intervals(void *log, struct sbg_script *s, int sample_rate, ev1 = &s->events[i]; ev2 = &s->events[(i + 1) % s->nb_events]; ev1->ts_int = ev1->ts; + + if (!ev1->fade.slide && ev1 >= ev2 && ev2->ts > INT64_MAX - period) + return AVERROR_INVALIDDATA; + ev1->ts_trans = ev1->fade.slide ? ev1->ts : ev2->ts + (ev1 < ev2 ? 0 : period); } From patchwork Tue Apr 27 19:21:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 27442 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6109:0:0:0:0:0 with SMTP id v9csp1242219iob; Tue, 27 Apr 2021 12:28:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8DrQXVNKf0WfuGxCmHssmQCKOLk+AkPcwcvyWIB6mVd504zyK915svV21oWHMPj84eKha X-Received: by 2002:a17:907:ea7:: with SMTP id ho39mr25146148ejc.315.1619551698055; Tue, 27 Apr 2021 12:28:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619551698; cv=none; d=google.com; s=arc-20160816; b=ZGTep9eP0lvZV/ON0Z9lfCq5JpW/c9z6tvGWWA6T7jvbzKV+RO0BeWrRStIPGiPj// 2g5VtXEMb7YgARIMv5IBj8qvqUTje17grlEDH4G/utstfm86jQVMlIfik5bdzfgNyZjE 1n6rdsOhRr8egoYHilf0Y913iR1+yEZEpF8yTNFNXmj57hlcBF633vdF+UQqpAbcIqmT IWQLwwljtfjW7YAeDp+mvKAEM0ib3Owqe3Tdc9kPOpM3gXmKW6XC+Vl72cm45qdZt2DB mDxte1mYlOOgAzGx5PGF4jrYC4UoOpKE3xNjLRJtF6cUevDgXBTsU0sGrMSFeEEDNRpf PUhQ== 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=3/OPKPJMtstrLg1uykfv9VP1zwdHwkFIJe1qddREkwI=; b=Td5Zcj5rP+1wUB0DuQZ9bHpccvJN/m3Hgq01s1Hi0aJcjxWRalWMLBAnha4rEYAcjz pXFJsT94xKKIUL04byDqdwd1RBE0dgOnOpCflwuCOz1I55cxxAbiyqFyQgAfCIMyeWwr mFxA2G66uAb+TxkHrsfw0X/79Tc062N7LMBFNlkpPJ8ZB0XdFNFOMX+i31/oucq6QJ2/ u7y8nx9vnW89y1z9LyL0pDsZ3TjtNTkoX26sV1jczY1E8mvg+bSC+lmAEgkxPSre6w0H 48GkDkN1foQF1wKBkS6zr9WHjQDMBwcC7QeST+jajoQmIDK9zGRp1ZESNdV8JX3cd3Dn h91w== 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 kb17si670109ejb.294.2021.04.27.12.28.17; Tue, 27 Apr 2021 12:28:18 -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 A57B468026B; Tue, 27 Apr 2021 22:28:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe01-3.mx.upcmail.net (vie01a-dmta-pe01-3.mx.upcmail.net [62.179.121.156]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C9C4C680835 for ; Tue, 27 Apr 2021 22:28:07 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe01.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1lbTI3-009HbL-Vp for ffmpeg-devel@ffmpeg.org; Tue, 27 Apr 2021 21:22:35 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id bTH6lEuQsljeHbTH6lFofv; 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=_gu8nYYhDGt3qoTxneIA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=SsAZrZ5W_gNWK9tOzrEV:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 27 Apr 2021 21:21:35 +0200 Message-Id: <20210427192135.17286-4-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 4/4] avformat/wavdec: Use 64bit in new_pos computation 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: J8fOULm75cFj Fixes: signed integer overflow: 129 * 16711680 cannot be represented in type 'int' Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_WAV_fuzzer-6742285317439488 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/wavdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c index e11535b6ae..af32d15092 100644 --- a/libavformat/wavdec.c +++ b/libavformat/wavdec.c @@ -718,7 +718,7 @@ smv_retry: if (wav->smv_last_stream) { uint64_t old_pos = avio_tell(s->pb); uint64_t new_pos = wav->smv_data_ofs + - wav->smv_block * wav->smv_block_size; + wav->smv_block * (int64_t)wav->smv_block_size; if (avio_seek(s->pb, new_pos, SEEK_SET) < 0) { ret = AVERROR_EOF; goto smv_out;