From patchwork Fri Jan 22 14:09:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 25094 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:ab61:0:0:0:0:0 with SMTP id u88csp1189672ybi; Fri, 22 Jan 2021 06:11:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwNxuI8lKQh8wamoHzHroPMddQjlRLUNTmQUtHOGZaER+bTmCYxIpKM0xrUEimk51zdTELn X-Received: by 2002:a17:907:1701:: with SMTP id le1mr3194667ejc.68.1611324669399; Fri, 22 Jan 2021 06:11:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611324669; cv=none; d=google.com; s=arc-20160816; b=FaaHlBcdXHuYoGKyAhBh4VAzZfdyiY2GcwxQnELa6h09rAmCyYFEQFP2nPVXryCFr1 ONrKZKEBW3rvm709VgKhHaAHmqlZOxBtCxDKa6y9jgLfV7CEV40vJzZcpQSDe2GVM6eh JOA3qevBDMYkFAsKiPXg7brIfvlGStjRZk42lC1S4pesnxV4yMWwZrsI+pG8aDL0mjUn m7vbaMnVe0GbbwzXWWHd9jnGT24+uVAOh1eIovBKZ15liEb0Sa0lM0mtulm/G5Ca5oYs 7FBDU3GcHGBOGR9BvlHloUrQ0BfYTRphVgoAwXbi4fOIp8JCjHbpQHpIOJWIiR71gfpr hF5A== 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=dJTmC54PjiWOslquKxbSL+bG66gphxLDoPzgtBrTgOA=; b=KShtfPJZaluqGqhZi83f+c5AGVUbrVnMhTdJT8r6mCubEICe1LH64ieJGvHL4Z7vcD +n6Dwat0pIv6t0srEvF6K6xVEyd8sq+F4mL4wcPtKCUEKje9FTQSnvtIb3d0MXhHeY5q yTkHF1C/wBVky0IKxqmSny6Ndkqpk41nLQN8PY4BU27vKthShXIMuJlaldyEvDdlKIcA wZbNp7MqMPhe+XtGobkN7vWY4rgdsrM5FvjfUUvo5IiaEeNe+NGuQ/FBQEtgHfdBzxew Wku9DZAWZWFHuqw70wxfL4vVz+60Fjrr9EYO8hNZlmwtaMPJQq1b/4JEOc7WvBz4VvRC OAvA== 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 n25si3693839edw.77.2021.01.22.06.11.08; Fri, 22 Jan 2021 06:11:09 -0800 (PST) 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 8516C68A34F; Fri, 22 Jan 2021 16:11:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe02-3.mx.upcmail.net (vie01a-dmta-pe02-3.mx.upcmail.net [62.179.121.159]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0EB1B6881FE for ; Fri, 22 Jan 2021 16:10:55 +0200 (EET) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe02.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1l2x9E-0004UM-0C for ffmpeg-devel@ffmpeg.org; Fri, 22 Jan 2021 15:10:48 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id 2x8FlwuyPO4rA2x8Gl7jJC; Fri, 22 Jan 2021 15:09:48 +0100 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=RNDN4Lq+ 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=x8M2Z-uFYYxGjLmzbRwA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=UDnyf2zBuKT2w-IlGP_r:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 22 Jan 2021 15:09:46 +0100 Message-Id: <20210122140947.18479-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfFjRgzlbAHWDaPcwUMcnPvJNGohTNBemws/uWqFX4pGl9bDr6XqKuvetM97j7bvI599JPmH/1QUZxm47xrAj+oxNP8/kDsTeAsGSmlK6nOZmO5oGIgsm /+lYLKgGfsWRclVGsqppe/Nr/Ej8uBwaCujl1E0kc732ZSc4RCDl9yjE Subject: [FFmpeg-devel] [PATCH 1/2] avformat/mxfdec: Fix integer overflow in next position in mxf_read_local_tags() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: rv9pomlOnEKH Content-Length: 1885 Fixes: signed integer overflow: 9223372036854775723 + 8192 cannot be represented in type 'long' Fixes: 29072/clusterfuzz-testcase-minimized-ffmpeg_dem_MXF_fuzzer-4812604904177664 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/mxfdec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index 4c932e954c..f1167761f9 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -2865,8 +2865,10 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadF int ret; int tag = avio_rb16(pb); int size = avio_rb16(pb); /* KLV specified by 0x53 */ - uint64_t next = avio_tell(pb) + size; + uint64_t next = avio_tell(pb); UID uid = {0}; + if (next > INT64_MAX - size) + size = 0; av_log(mxf->fc, AV_LOG_TRACE, "local tag %#04x size %d\n", tag, size); if (!size) { /* ignore empty tag, needed for some files with empty UMID tag */ From patchwork Fri Jan 22 14:09:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 25085 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:ab61:0:0:0:0:0 with SMTP id u88csp1193579ybi; Fri, 22 Jan 2021 06:16:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcyBR/4MtT3yJ9U7bdnV1+9QAeD2GPoafP40eP5f7ZGe4btW39ROMO42QW2hfxezBQf8gg X-Received: by 2002:a05:6402:2707:: with SMTP id y7mr3236416edd.5.1611324980794; Fri, 22 Jan 2021 06:16:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611324980; cv=none; d=google.com; s=arc-20160816; b=0uJVefmW17K0n8GVwVWzA7LbMaCEANLEYFTzKXF007bVtEjuoKyNDHu53ChK6UbEhK b0w0Ao7iMfQlj+m1mN/cIDK91ucTYjgs4pttJH73wwsqxW4GvCGXuQhiJLrFQdIPasYw aKn+26c5dA0CLQchi7efUOjrw9g5u+irWHTEqY8YSNY0UVvziDrczXWx15G9k4veS0QK Y3jkeNOcQUaT5JR1HOL/xAmtd9+EJ9UJma2rnYVhhQhryx8+KqWTmZDqs1BKBgJRD3VW U9VydZmEpI32Q9vcGWrX3PVVcTR2D2hDBIuh7G9HlG/RryW9mF4v/j+zsQLxsEKQ1iav ZtMg== 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=k0ae50DR/MgkcSL1aKN3vRS419dpgQQpPqc8fDmm5cM=; b=Tys9gfTxM4Xy/R5HdX0/uFBvzsYdkHQZWvd4DG3SaYEQixosEPKua8xihIzt7V74Nr +HAZ8gfd+wjkqPVcvtMaj2UjTrS4Jix0R+yyzSvt4NaeFN45Nv194SViuuxaBtqTYN8h JHT1amjaVnoSL1w/+lY+a5qfJZfaEptfU9gWD16hu3EeZmufMziyuXY6SbacW8aCovbu HTNUFwN7D0hE6aUtl0uJYcBBo+HcjvgN+N63gs9Ldb8GOAW418gDB2vTrj2swvcznR+y jmG3OrRpkLPDxdFu3dfwuy4OmDzR9FVZgyyDY9bNBlPo0fFelqKjYICeeQ64aa8iV15a IxmA== 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 a27si2983343ejc.18.2021.01.22.06.16.20; Fri, 22 Jan 2021 06:16:20 -0800 (PST) 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 3622D68A435; Fri, 22 Jan 2021 16:16:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe05-2.mx.upcmail.net (vie01a-dmta-pe05-2.mx.upcmail.net [84.116.36.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 77081680A4B for ; Fri, 22 Jan 2021 16:16:09 +0200 (EET) 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 1l2x9E-0005ea-0D for ffmpeg-devel@ffmpeg.org; Fri, 22 Jan 2021 15:10:48 +0100 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id 2x8GlwuzkO4rA2x8Gl7jJV; Fri, 22 Jan 2021 15:09:48 +0100 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=RNDN4Lq+ 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=scvl_rpCFz6HfmbDL4EA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=SsAZrZ5W_gNWK9tOzrEV:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 22 Jan 2021 15:09:47 +0100 Message-Id: <20210122140947.18479-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210122140947.18479-1-michael@niedermayer.cc> References: <20210122140947.18479-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfFjRgzlbAHWDaPcwUMcnPvJNGohTNBemws/uWqFX4pGl9bDr6XqKuvetM97j7bvI599JPmH/1QUZxm47xrAj+oxNP8/kDsTeAsGSmlK6nOZmO5oGIgsm /+lYLKgGfsWRclVGsqppe/Nr/Ej8uBwaCujl1E0kc732ZSc4RCDl9yjE Subject: [FFmpeg-devel] [PATCH 2/2] avformat/swfdec: Check outlen before allocation X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: LHmabobPSaDR Content-Length: 1630 Fixes: Timeout (too long -> 241ms) Fixes: 29083/clusterfuzz-testcase-minimized-ffmpeg_dem_SWF_fuzzer-6273684478230528 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/swfdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c index 1463f0ad4d..aa4be88f91 100644 --- a/libavformat/swfdec.c +++ b/libavformat/swfdec.c @@ -367,6 +367,9 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) ff_dlog(s, "bitmap: ch=%d fmt=%d %dx%d (linesize=%d) len=%d->%ld pal=%d\n", ch_id, bmp_fmt, width, height, linesize, len, out_len, colormapsize); + if (len * 17373LL < out_len) + goto bitmap_end_skip; + zbuf = av_malloc(len); if (!zbuf) { res = AVERROR(ENOMEM);