From patchwork Fri Jun 7 21:56:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 13455 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 59C66447E5F for ; Sat, 8 Jun 2019 00:57:53 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 29FED68AA22; Sat, 8 Jun 2019 00:57:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe06-1.mx.upcmail.net (vie01a-dmta-pe06-1.mx.upcmail.net [84.116.36.14]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 253ED68A9F3 for ; Sat, 8 Jun 2019 00:57:47 +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 1hZMrq-0009No-3a for ffmpeg-devel@ffmpeg.org; Fri, 07 Jun 2019 23:57:46 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id ZMqrhg2Di5D5NZMqshLyTJ; Fri, 07 Jun 2019 23:56:46 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.41.20 X-CNFS-Analysis: v=2.3 cv=bu8y+3Si c=1 sm=1 tr=0 a=I1eytVlZLDX1BM2VTtTtSw==:117 a=I1eytVlZLDX1BM2VTtTtSw==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=SBKM1Q4NjMnoed1RYZoA:9 a=1fhp2MxaeJtTNGEnv6mo:22 a=pHzHmUro8NiASowvMSCR:22 a=nt3jZW36AmriUCFCBwmW:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Fri, 7 Jun 2019 23:56:17 +0200 Message-Id: <20190607215619.20992-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-CMAE-Envelope: MS4wfAVuOGAEb/8kFzSrs9cMhsKaD6CZ3QKlxiV6tFMTYPvXtVo6fdKgnlzNXrVWKIGLO/eToM72WN2sblm9FyBHryN2hYIVNujeX9+YTBJGLehw53onmANb /7Dk/KbGA6ZSy9ZQs46pRJAEu46JAZq2q7whXd7QPgPkbLiVeNqY2sXI Subject: [FFmpeg-devel] [PATCH 1/3] avformat/jacosubdec: Fix timeres to 1/100 units convertion overflow 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes: signed integer overflow: 44444442 * 100 cannot be represented in type 'int' Fixes: 15117/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5164660531134464 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/jacosubdec.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c index 50144f7e21..121c86d659 100644 --- a/libavformat/jacosubdec.c +++ b/libavformat/jacosubdec.c @@ -107,6 +107,7 @@ static const char *read_ts(JACOsubContext *jacosub, const char *buf, unsigned hs, ms, ss, fs; // hours, minutes, seconds, frame start unsigned he, me, se, fe; // hours, minutes, seconds, frame end int ts_start, ts_end; + int64_t ts_start64, ts_end64; /* timed format */ if (sscanf(buf, "%u:%u:%u.%u %u:%u:%u.%u %n", @@ -124,10 +125,10 @@ static const char *read_ts(JACOsubContext *jacosub, const char *buf, return NULL; shift_and_ret: - ts_start = (ts_start + jacosub->shift) * 100 / jacosub->timeres; - ts_end = (ts_end + jacosub->shift) * 100 / jacosub->timeres; - *start = ts_start; - *duration = ts_end - ts_start; + ts_start64 = (ts_start + jacosub->shift) * 100LL / jacosub->timeres; + ts_end64 = (ts_end + jacosub->shift) * 100LL / jacosub->timeres; + *start = ts_start64; + *duration = ts_end64 - ts_start64; return buf + len; }