From patchwork Fri Apr 23 17:50:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 27221 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:5014:0:0:0:0:0 with SMTP id e20csp1749885iob; Fri, 23 Apr 2021 10:52:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGeum9ECCsA1dDgtCEDE+50FUqyJPi2+/gapv6jLZjMNc4jsP4+7U2mm6TV70MZDERH87M X-Received: by 2002:a17:906:6bcb:: with SMTP id t11mr5476965ejs.395.1619200352799; Fri, 23 Apr 2021 10:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619200352; cv=none; d=google.com; s=arc-20160816; b=vAJTk/Wkfzju1+wiEyjT2Abbnpc1WdpYvfhV/Zb/FxnSMnk4erjooanmrxMzlTNwyu yJwp2uM4ivdLAnvS/kgsjsqU//6WsKRdly5iuYYHzpLunRvvndzDkiJ55KRsCrDRI5yX +0ONt+HxytNpXrRFwfn1TlbgJepb4ELMYAGTTV9gEiQ+6gYXWJU7wyyVBRqrSVUXV0W1 FfJhOA4WGH6Sg5gtJVm94ByH6673nmCS1Df72rSHJNmNL5KPH0LB7d0Aqf7YBZLUICP9 Hl45/4rjox6Qr3jl4PI1us5CQr/zJPBWH1Ow421DvshhvrQb5jGMqsDBFT8mCqGpqroj CRXQ== 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=9xPgdNfYt2nheuJvycJBngOCfGaHbafeWbi43klDeb8=; b=mgOoq70H3HoGmCN0l/xpTXhrR3fTF1/TV3p97n4fF3kRmyvsrGVZLGA/DWlshIxM2O qNF4NbiBvjQyXgoUmSNRFVSBq6tfmzRVGSqRqV6r432kc1XCiIisUltStOORyhjET/bn BJXbCczYnDWjqq3O4RxKAWNrmeW86FjFhOcg2dspHklZgOXhcLZDMU9wae7TmC02BYuI GBOD6RF6PS0w/QYdZXdPmno30Ucpseyq6bpGZtZPAmJXZ59TZKwi5NF9Q6qunahENhNE mIX7HQvjn4TqVSi2iLDx8LnAMdJkAGUtwBwx4IXsXmQV19H6pHD0VSuITcbTkFmJkPUg 4iWw== 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 z2si5836826ejx.497.2021.04.23.10.52.32; Fri, 23 Apr 2021 10:52:32 -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 38D1A689DC4; Fri, 23 Apr 2021 20:52:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe05-3.mx.upcmail.net (vie01a-dmta-pe05-3.mx.upcmail.net [84.116.36.13]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C253D6898E3 for ; Fri, 23 Apr 2021 20:51:57 +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 1lZzy9-00336y-0I for ffmpeg-devel@ffmpeg.org; Fri, 23 Apr 2021 19:51:57 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id ZzxBlGeZ4ljeHZzxBlb2oQ; Fri, 23 Apr 2021 19:50:57 +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=UlA4yjZwH3SWBeAk2-EA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=UDnyf2zBuKT2w-IlGP_r:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 23 Apr 2021 19:50:52 +0200 Message-Id: <20210423175056.24019-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210423175056.24019-1-michael@niedermayer.cc> References: <20210423175056.24019-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfKPM2k8SHcfE0jCKoBXOCwCY6kBDQ7MZRVMFl7KnG8xwlNW6ve546x6zkU8nbidRcnd4w+Vx7ZQjGv68H+PxwsDfyTdnhcwgQmCYGQ4Avp07A5u0M6p8 GZLuyKjGqdngI8hkCMU3T1kGzhK7BI0bQi8qL/ZXGIVr6jJgbexNH5Iw Subject: [FFmpeg-devel] [PATCH 3/7] avformat/asfdec_f: Check sizeX against padding 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: BhURwJxCN8x8 Fixes: signed integer overflow: 2147483607 + 64 cannot be represented in type 'int' Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_fuzzer-6753897878257664 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/asfdec_f.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c index 27162e9559..18d637b1a4 100644 --- a/libavformat/asfdec_f.c +++ b/libavformat/asfdec_f.c @@ -415,7 +415,7 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size) tag1 = avio_rl32(pb); avio_skip(pb, 20); if (sizeX > 40) { - if (size < sizeX - 40) + if (size < sizeX - 40 || sizeX - 40 > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) return AVERROR_INVALIDDATA; st->codecpar->extradata_size = ffio_limit(pb, sizeX - 40); st->codecpar->extradata = av_mallocz(st->codecpar->extradata_size +