From patchwork Tue Mar 6 14:43:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 7822 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.181.170 with SMTP id m39csp3841138jaj; Tue, 6 Mar 2018 06:43:29 -0800 (PST) X-Google-Smtp-Source: AG47ELtLmg5/i/6orSmICxr5Opy47JMYrfcy/1WJKXOfocm6Ytcc2HvrTiwGBUko2+U9bllqZ6uc X-Received: by 10.28.71.204 with SMTP id m73mr8575669wmi.111.1520347409435; Tue, 06 Mar 2018 06:43:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520347409; cv=none; d=google.com; s=arc-20160816; b=kFv8Q51T/YMkc2hebI+/rNIcKpWIstN/xt198fSzSILh1UsNf7zhAF1+eJuqydt+rG NFzZGAqSc1jTeY4tOo7YO4C3PXT+FMQY43KGGIfbt7l5GSW4drM3S4TPXDqAKskaqO94 T28AN8OMVeROl1kvsXNqEraIGHlIMOtMoVRo0MdtjxStwyr4etHptahBF/b5kDC2m/p/ IhmrzN1U4tZrcXv7FSTpgGCJw1MS3jwo9kYWHpIUtgEN3gu7XrBSQm170BiqJuxS6rJB pmRwIzTSpt28j2UKH8MTmEZELQLM29SrxTVh7jrxSny9EgGch4sXD315OlUmK63Jiugf mhpw== 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:arc-authentication-results; bh=YXX30TFU+/GlDItEkqnxjPORXu8wWXEP4YDNVMf/pZY=; b=mBba/Po3arx9cFm61aMY3Pk5alZnbhPb9nDi2Ytjx84uLf0L+JTE3hYFAODSrHUZmh SEi8SP1XFUbgu7C9KBVGKFt2lkyZnr0YgdJ7MvoPJuuXruoZPYbff2zAetv2dBXn0y9z 3Kt2wV54qmO3LBw15AMLur184v36Bz2j3ia70OCuolvO2uaDuknzp3WVUhil7ZuzdXFk PqixuuqM8Us3BPbMA1xCQKdi5Sf6xsGrlOhCv29duwlWLRSLz9ioEPDKHh86JRrUm8kx gpLk9cVG8LgPu7JMfTtwOM/xqoY61sARtzinQfGX789dykdjQB4b9wUWqbj6CbtJzdtK CLgA== 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 l7si282455wrb.54.2018.03.06.06.43.29; Tue, 06 Mar 2018 06:43:29 -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 38D6368A4F1; Tue, 6 Mar 2018 16:43:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe07-1.mx.upcmail.net (vie01a-dmta-pe07-1.mx.upcmail.net [84.116.36.17]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0791968A4E7 for ; Tue, 6 Mar 2018 16:43:14 +0200 (EET) Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe07.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1etDoH-0007yT-8o for ffmpeg-devel@ffmpeg.org; Tue, 06 Mar 2018 15:43:21 +0100 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id JejC1x00o0S5wYM01ejDsw; Tue, 06 Mar 2018 15:43:13 +0100 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 6 Mar 2018 15:43:06 +0100 Message-Id: <20180306144306.18665-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180306144306.18665-1-michael@niedermayer.cc> References: <20180306144306.18665-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avformat/mov: Fix integer overflow in mov_get_stsc_samples() 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" Fixes: runtime error: signed integer overflow: 5 * -2147483647 cannot be represented in type 'int' Fixes: Chromium bug 817338 Reviewed-by: Matt Wolenetz Reported-by: Matt Wolenetz Signed-off-by: Michael Niedermayer --- libavformat/mov.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 95b9cd3f8b..7002a82787 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2645,7 +2645,7 @@ static inline int mov_stsc_index_valid(unsigned int index, unsigned int count) } /* Compute the samples value for the stsc entry at the given index. */ -static inline int mov_get_stsc_samples(MOVStreamContext *sc, unsigned int index) +static inline int64_t mov_get_stsc_samples(MOVStreamContext *sc, unsigned int index) { int chunk_count; @@ -2654,7 +2654,7 @@ static inline int mov_get_stsc_samples(MOVStreamContext *sc, unsigned int index) else chunk_count = sc->chunk_count - (sc->stsc_data[index].first - 1); - return sc->stsc_data[index].count * chunk_count; + return sc->stsc_data[index].count * (int64_t)chunk_count; } static int mov_read_stps(MOVContext *c, AVIOContext *pb, MOVAtom atom) @@ -7189,12 +7189,13 @@ static int mov_seek_stream(AVFormatContext *s, AVStream *st, int64_t timestamp, /* adjust stsd index */ time_sample = 0; for (i = 0; i < sc->stsc_count; i++) { - int next = time_sample + mov_get_stsc_samples(sc, i); + int64_t next = time_sample + mov_get_stsc_samples(sc, i); if (next > sc->current_sample) { sc->stsc_index = i; sc->stsc_sample = sc->current_sample - time_sample; break; } + av_assert0(next == (int)next); time_sample = next; }