From patchwork Thu Jun 24 20:57:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 28709 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:bbc9:0:0:0:0:0 with SMTP id c9csp661437ybk; Thu, 24 Jun 2021 13:59:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGXL5ENcZdyABLT3rMgbscPLmhwySE3144fT4Q7qxfEgWNyENBZTMtfXHN9Y8u1NVXPNPm X-Received: by 2002:a17:906:3042:: with SMTP id d2mr7318696ejd.234.1624568372652; Thu, 24 Jun 2021 13:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624568372; cv=none; d=google.com; s=arc-20160816; b=jlNTnWWISeAkxSC/TKKzn7GT5Th5xWYDNrhKxd0CUdsDkIlB7ZeJHUt3GkLOnsgyxk H9aLPeUgohBmdglRkorLPd2ikNoWDpcJXJ7mqXREFcYHnQdeH1FDFAIo2Ej9+XjjZ32I Qev1urGZNgLG4D04qnQBxgq+OxQlffDQNk9p8Pi+O+VkOC89nrAPaZ6mJ56ayOOSjboT fxHkDgcyQ2pIxbNGRoZ3YgSqn4fJkNyodqP9FIlxdhmbTK/ck1Gq4GvGZnGlusr3QzOp ZDc8dyAbnHRPL2RFXNw/kq8QXlRnuSwz0bFwkxYRZlHMdjL6xVNoRNba59XvkPPox0P0 hAmg== 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=u8t8KuRqYZP4YgLkgQGrc30eJe6znp4Lfb0stPr2+Wg=; b=qAK7xz8rAiLiMuum/6wgRMiHMYl2JgSLrdCRhhu8BOJMLSWRNNnZLViQStKbrxiPZD Z//dW6KbaSVWw+PIJ5830NUZkJBk0G1wfw9KqoA8yIHsryOew0pqXaQLnteB3OIlJffJ 6XeeNH/WTTi8ub6dIjN/206ZCzrSSG0nEoHvy9uAhET5EXBLt7qzMo3elhh05LWmB13a hcT/xcnRU025OeMriWF+YRtHYNNzud/cgPehHR9iExIFpLFOXTQGyaNOGvxQqWiXeV1b jsg+LBBwYgbiR/5xD5+lkMB2J1BhNORdrdCJNfl9MuuHCe0dSQDeGvxWZZFkeEgZ7SKf VDOQ== 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 z12si3986852edr.197.2021.06.24.13.59.32; Thu, 24 Jun 2021 13:59: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 DBF4C689E9A; Thu, 24 Jun 2021 23:59:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe03-3.mx.upcmail.net (vie01a-dmta-pe03-3.mx.upcmail.net [62.179.121.162]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 45A0F680A37 for ; Thu, 24 Jun 2021 23:59:25 +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 1lwWRZ-004sG5-0C for ffmpeg-devel@ffmpeg.org; Thu, 24 Jun 2021 22:59:25 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id wWPdljwI5ljeHwWPdlKH6D; Thu, 24 Jun 2021 22:57:25 +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=Sdm7alShjlkCdyBeoRIA:9 a=1fhp2MxaeJtTNGEnv6mo:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 24 Jun 2021 22:57:23 +0200 Message-Id: <20210624205724.18711-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210624205724.18711-1-michael@niedermayer.cc> References: <20210624205724.18711-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfHBDzQJnTWjw2CF5s+ovATNUXP79eOS/HJLbVxX4yZ/czCCqE5AlSytXfQCZzH2F1Ss5Q+HZ7HY4lIE2gfuQMND72cpJcHDpvtuAMKf7MNQ1RmV024cm 2sHggDNM9YAFOv7V240TT+JdFNfX3Dwx+FBtHiEOfCSyFq1vhTsM7qOo Subject: [FFmpeg-devel] [PATCH 2/3] avformat/sbgdec: Check opt_duration and start 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: cDDyahxNWMDH Content-Length: 1342 Fixes: signed integer overflow: 2788626175500000000 + 7118941284000000000 cannot be represented in type 'long' Fixes: 35215/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6123272247836672 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/sbgdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c index dafdc4a1cc..0a6e927e57 100644 --- a/libavformat/sbgdec.c +++ b/libavformat/sbgdec.c @@ -935,6 +935,9 @@ static int expand_timestamps(void *log, struct sbg_script *s) } if (s->start_ts == AV_NOPTS_VALUE) s->start_ts = (s->opt_start_at_first && s->tseq) ? s->tseq[0].ts.t : now; + if (av_sat_add64(s->start_ts, s->opt_duration) != s->start_ts + (uint64_t)s->opt_duration) + return AVERROR_INVALIDDATA; + s->end_ts = s->opt_duration ? s->start_ts + s->opt_duration : AV_NOPTS_VALUE; /* may be overridden later by -E option */ cur_ts = now;