From patchwork Fri Apr 23 17:50:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 27223 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:5014:0:0:0:0:0 with SMTP id e20csp1749679iob; Fri, 23 Apr 2021 10:52:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxQcU2WU6doBKXW4sAB5NAV2Wd7N8iY+3jsspcv55q1rwrwXt565hYR7vxxLmZrK6+S+Tc+ X-Received: by 2002:a17:906:af5a:: with SMTP id ly26mr5385743ejb.372.1619200329851; Fri, 23 Apr 2021 10:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619200329; cv=none; d=google.com; s=arc-20160816; b=xqpnEQg5SD36b9hO+201GeD41thDI2zC/PzIghmP+dREjU88svtENR4KgEN6KnC6+Q lXgQtWPx2Goa/aKwGskrkZHMlzkQqgoGWvq0h/XCdjLdMPRJyYu1Pgko4ibmML/gzR5H oAydHGJl6Klnz9KOWa87C6kZu51r70jVj18H4PsFSGCHi762QyF+H2GmsX64dWoenElu /DrzhoIXFDSwpCwdYyBXIyDqCyPf3IaXi6ozNWwkqI8jxPfRXa73xxFRWRlwvL1clkX+ RZy3Pwn9urHHMAhG8k//WMNXea9Ec+Abypbct1AViu+icj61b/K+Lih/B93O6ZVDNSzz 4EPw== 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=Vo9KFKOQ+F4O/rj+9naIaK0BplKX9QZBt3zTR7SwVSw=; b=G07tgSn+T7p0P0K4+tZju0Hsbh1OTLTQQRKPBoa09M7cJf/yoJyeP63lm1iSBimd7P kkWRY3Lr9hEsHzAYIYRHb1M4/Nf5c+E5djJbDuarxBowaNVgn28Qs4scbEqF5ZWFIdoP ezP1lNeHZuyIrKLZRFimYa1I6wLcbHGBcNjo1SOdXUg1WH8nkY12NI60imMAr/PFpMhe 12KKHnXPm2a8cIsgCKrkh+wRG37etQpN60LpqHdv8gp3Vid5Ht4VfC/A64sAqN85VaBO 5S7+UdZAFSX75cgtmOyJB3h8oaVV7lrjNH1GyqUPdOZlZQfIEmyACMvwKKA8IZyEszBT 4ZyQ== 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 p23si6577798ejg.550.2021.04.23.10.52.08; Fri, 23 Apr 2021 10:52: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 03EF4689CA7; Fri, 23 Apr 2021 20:52:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-2.mx.upcmail.net (vie01a-dmta-pe06-2.mx.upcmail.net [84.116.36.15]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BE5D7688124 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-pe06.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1lZzy9-0009Ui-0F 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 ZzxBlGeYsljeHZzxBlb2o9; 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=T98hxhEdsUayia65omUA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=Z5ABNNGmrOfJ6cZ5bIyy:22 a=SsAZrZ5W_gNWK9tOzrEV:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 23 Apr 2021 19:50:51 +0200 Message-Id: <20210423175056.24019-2-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 2/7] avformat/aiffdec: Check for size overflow in header parsing 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: 22fqC11SMM7L Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int' Fixes: 29102/clusterfuzz-testcase-minimized-ffmpeg_dem_AIFF_fuzzer-6723467048255488 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/aiffdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/aiffdec.c b/libavformat/aiffdec.c index 1b693b71a3..7ec408b2e6 100644 --- a/libavformat/aiffdec.c +++ b/libavformat/aiffdec.c @@ -100,6 +100,9 @@ static int get_aiff_header(AVFormatContext *s, int size, int sample_rate; unsigned int num_frames; + if (size == INT_MAX) + return AVERROR_INVALIDDATA; + if (size & 1) size++; par->codec_type = AVMEDIA_TYPE_AUDIO;