From patchwork Fri Aug 25 10:37:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 4832 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.15.201 with SMTP id 70csp300367jao; Fri, 25 Aug 2017 03:37:42 -0700 (PDT) X-Received: by 10.28.181.20 with SMTP id e20mr946262wmf.15.1503657461898; Fri, 25 Aug 2017 03:37:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503657461; cv=none; d=google.com; s=arc-20160816; b=keABemyHebzVcrvYzm2nwEuhi6otyZhkaOcdkv/925VZKgsWplXdHW7V7EZdLS53o5 ub4II/RrL37qCiP+zKicxTL9lZtYiAnrrEXA1XWNmBcjUCdZtYWnqjCdf+Ulbv3JhE9O ISa5hyA3IMoKGnjlGHyJ7Ly+WyQVV0f5+1T7TKzTmqaEnh2sUIdCiwnGfikc8LpSoAuU 9vKwppjrhRHbVCCK2UKd5MBWe48OYwRhNk7obzGJ6qVayCgG58h522180G6VTYv5hokn 5SJwOLvyTUUlRMp2aFezUGVKMWrYm3aibxQgld5yLvkhNyUb1ERxSEUKULUwyE9rxBov t4Mg== 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:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to :arc-authentication-results; bh=weW7s3NuqsN0nKSnRP2hBX6jyVvNeEJzEEjsLtzLs8Y=; b=y24XAYRCoX+I4EpSBlt0avs9gtItXfuoZ3c6Ch0dw8diDGdBsaR2aZwRuI7k+eTihq HW+87AX9CwQ2Z3eGJuq/ZvbPtdT11ILTiyxmQ8decBkaiHFOZ19LDJB8ePtryEsdk0J+ 3fkML+rxFBb4oXKtGKhQXvOjPUhDlPl+pVAAU4UEVdxOupp59vL2tn90hLEFNolwMJY6 KgMfobiuqyM2jjdST4Tu3AeNJtSiYwQFxQ32h+6b3Mbe3peUsVDXhCqgqa5JGeI+hmL/ 93zLrP0YFL+PU7MGYpjSRvjUH9JCzBAl/xPK40fLCA6qq0ELgNyXMtN69k8lqutzEJ/G K42w== 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 s133si989309wmb.204.2017.08.25.03.37.41; Fri, 25 Aug 2017 03:37:41 -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 C8C4B6898F0; Fri, 25 Aug 2017 13:37:29 +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-pe06-1.mx.upcmail.net [84.116.36.14]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 96BFA68971B for ; Fri, 25 Aug 2017 13:37:23 +0300 (EEST) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1dlBzX-0005Gi-OQ for ffmpeg-devel@ffmpeg.org; Fri, 25 Aug 2017 12:37:31 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id 1NdR1w01Q0S5wYM01NdS66; Fri, 25 Aug 2017 12:37:26 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 25 Aug 2017 12:37:25 +0200 Message-Id: <20170825103725.11463-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.14.1 Subject: [FFmpeg-devel] [PATCH] avformat/asfdec: Fix DoS due to lack of eof check 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 Cc: "wangchu.zhl@alibaba-inc.com" MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: "wangchu.zhl@alibaba-inc.com" Fixes: loop.asf Found-by: Xiaohei and Wangchu from Alibaba Security Team Signed-off-by: Michael Niedermayer --- libavformat/asfdec_f.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c index be09a92bd1..f3acbae280 100644 --- a/libavformat/asfdec_f.c +++ b/libavformat/asfdec_f.c @@ -749,13 +749,15 @@ static int asf_read_marker(AVFormatContext *s, int64_t size) count = avio_rl32(pb); // markers count avio_rl16(pb); // reserved 2 bytes name_len = avio_rl16(pb); // name length - for (i = 0; i < name_len; i++) - avio_r8(pb); // skip the name + avio_skip(pb, name_len); for (i = 0; i < count; i++) { int64_t pres_time; int name_len; + if (avio_feof(pb)) + return AVERROR_INVALIDDATA; + avio_rl64(pb); // offset, 8 bytes pres_time = avio_rl64(pb); // presentation time pres_time -= asf->hdr.preroll * 10000;