From patchwork Thu Jun 24 20:57:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 28612 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2042:0:0:0:0 with SMTP id z2csp823313iod; Thu, 24 Jun 2021 13:58:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSOB69+tLra87djY0y+ad10nUY6vlBU3qG4/VaJe5mTJEPJp5of2xqtdnEsq3CYyF1ykN8 X-Received: by 2002:a05:6402:2687:: with SMTP id w7mr9869641edd.98.1624568327395; Thu, 24 Jun 2021 13:58:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624568327; cv=none; d=google.com; s=arc-20160816; b=lmQYICTjZRY9SrG5b5ajCSiQ4QjvsSi2MITZKPZjcayfPiLWLEX7Wjk2eBReLfabJO Amggsx7dMdBZeeB9R9ndR4gJktGAvZYUzsjcxACpYcrAKXNVBUhuoAPgX5TqQrdywgV2 wbKm09nhe6G1sQvRlV5+lj7O4m95bnDNGjC7KZ9/ngTMlu4I70A/w2pU1TGKMoOM8KjN jxo7xG8lwHBJeiwRK/ZeI6msrkIqYzjXjMAygdV4QAhcOzoIrB6snIqIYQq5UDzI30ki Bt3Isjwp7SQQFMy98F65WRAY7aLcMIewsOaYrawNvGxr68N7qDrB9Nrg8qdzttME5C2G UPug== 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:message-id:date:to:from:delivered-to; bh=bZ8jYGAbO/E8YUQv5says2+3AqbNQJB2Oh/O64A4cxg=; b=W+2KSfAFz8xVYYYdm3v8q7By7ruSwXbmMRmGQ8/mwb9hSYNRdtT0wJWM6ZIdNsNnzd dMDaThHwV0dctTvWZgz4SF1IfkMXoVSddRN24yMuSBKxr3i5CT4l38lZJ+h8Ov+qROWl O8mZDZGSmvDNwGZUS2viayFE283KRl5nPHUk+pfMWl3gHmDuk3LyqmMgfTLpSiDwVsa6 8jk33SWOhzzLnVNxnl5C3oz/uKwopVSfd8KRvpC9/qEDRSTTJEz9vlDRLTVe5YztQmmH r2KPdpx32L1pjEPJy6OaO4r4KJyyjOw7KEVM7RWfFz7E4XYIwYksyH+mS/dQEdUc9TZh hLiw== 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 dq21si3624521ejc.595.2021.06.24.13.58.47; Thu, 24 Jun 2021 13:58:47 -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 12A47689969; Thu, 24 Jun 2021 23:58:34 +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 EBE886809A7 for ; Thu, 24 Jun 2021 23:58: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 1lwWQb-004sG5-0M for ffmpeg-devel@ffmpeg.org; Thu, 24 Jun 2021 22:58:25 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id wWPcljwGaljeHwWPdlKH5K; 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=gbekUa7by_NmWyUsaaoA:9 a=1fhp2MxaeJtTNGEnv6mo:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 24 Jun 2021 22:57:22 +0200 Message-Id: <20210624205724.18711-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfHBDzQJnTWjw2CF5s+ovATNUXP79eOS/HJLbVxX4yZ/czCCqE5AlSytXfQCZzH2F1Ss5Q+HZ7HY4lIE2gfuQMND72cpJcHDpvtuAMKf7MNQ1RmV024cm 2sHggDNM9YAFOv7V240TT+JdFNfX3Dwx+FBtHiEOfCSyFq1vhTsM7qOo Subject: [FFmpeg-devel] [PATCH 1/3] avformat/matroskadec: Reset state also on failure in matroska_reset_status() 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: PGJxbqycwpi9 The calling code does not handle failures and will fail with assertion failures later. Seeking can always fail even when the position was previously read. Fixes: Assertion failure Fixes: 35253/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-4693059982983168 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/matroskadec.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 356a02339c..a0e6e0cf8b 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -804,20 +804,22 @@ static int matroska_read_close(AVFormatContext *s); static int matroska_reset_status(MatroskaDemuxContext *matroska, uint32_t id, int64_t position) { + int64_t err = 0; if (position >= 0) { - int64_t err = avio_seek(matroska->ctx->pb, position, SEEK_SET); - if (err < 0) - return err; - } + err = avio_seek(matroska->ctx->pb, position, SEEK_SET); + if (err > 0) + err = 0; + } else + position = avio_tell(matroska->ctx->pb); matroska->current_id = id; matroska->num_levels = 1; matroska->unknown_count = 0; - matroska->resync_pos = avio_tell(matroska->ctx->pb); + matroska->resync_pos = position; if (id) matroska->resync_pos -= (av_log2(id) + 7) / 8; - return 0; + return err; } static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos) @@ -1873,6 +1875,7 @@ static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, uint32_t saved_id = matroska->current_id; int64_t before_pos = avio_tell(matroska->ctx->pb); int ret = 0; + int ret2; /* seek */ if (avio_seek(matroska->ctx->pb, pos, SEEK_SET) == pos) { @@ -1897,7 +1900,9 @@ static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, } /* Seek back - notice that in all instances where this is used * it is safe to set the level to 1. */ - matroska_reset_status(matroska, saved_id, before_pos); + ret2 = matroska_reset_status(matroska, saved_id, before_pos); + if (ret >= 0) + ret = ret2; return ret; } 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; From patchwork Thu Jun 24 20:57:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 28611 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2042:0:0:0:0 with SMTP id z2csp823204iod; Thu, 24 Jun 2021 13:58:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyB/yuSFgbmws0LUL6Q0s+R0/HyaBPltUgS48omEJbbPMeD6KNcnLlwLmYC4HquTZv4YA7I X-Received: by 2002:a05:6402:2ce:: with SMTP id b14mr9858811edx.23.1624568317531; Thu, 24 Jun 2021 13:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624568317; cv=none; d=google.com; s=arc-20160816; b=ldnzT1sh3b5Mmo5NHJn7s5GAKZzHAndQxROfGUb5V/ljNEuz+XNXf3X3qjDJeMUoLX +0N5iHF7T7uCmWUF0lli5DuosbeasPm1BnW/LibSEvmkLB1B/lH3KsH53ZIeUkyIhxcx UT9PQ+lZ/vKOyVKJraRYqs4KL75BGeq3IFOKW/eXjpCKOHU03Up8afvfluWBIJHTHey2 XwtCRqtqBarhJ5PWAxM09lnOfXVKr/fA1jTZMKGnM0loMAKOKFIF7X83DSxmNVBlr+qq JXL52jRwKVVtAqPpJZvnQfSkw0YuVS1UYbIpzGDoOMg+UfrS7mg7n3Qq4FhGs2k8YBSe 6gww== 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=XzdHQDpFkzAKNxTQrMGow4ibLi3qPblKSpbJYaLWTto=; b=ylbW0W3Hced4+RN7fszpAjsxE1N58JV2j6cS3kzEB6aVBpSR7ejZmzN46ryT0/5rSi 1qinncAU0o/tn5ZiiYQXPqbVUFN4tBbt3ZPwk5oPfX4sByOMBysKXrukuyMMjQs6f7eM z23BViTBfQjP2/B4zO+b21FoQ3Xe7gUVGY9gUg5klnyrTsgM217MG0IaX/HONl3aijVG otVuYwmWIuWBqpIZO+6At0phzVsz09kjhcZGwRuZGKWas4LMFfEL7UZKKDeoypNzluzn xPSUxiL2rB9bcuLyLAbrQ7KGnRQ25FG/NhEHsmN5jNDjsHXvHQ8oPObLtDDCoJ+kFtkt Lyxg== 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 bm24si3676236ejb.577.2021.06.24.13.58.36; Thu, 24 Jun 2021 13:58:37 -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 B1D9D689CB4; Thu, 24 Jun 2021 23:58:32 +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-pe05-1.mx.upcmail.net [84.116.36.11]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DA5EB680968 for ; Thu, 24 Jun 2021 23:58:25 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1lwWQb-00AYzX-0M for ffmpeg-devel@ffmpeg.org; Thu, 24 Jun 2021 22:58:25 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id wWPdljwIQljeHwWPdlKH6S; 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=V0WZ6kAYpv2MOW3VQV4A:9 a=1fhp2MxaeJtTNGEnv6mo:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 24 Jun 2021 22:57:24 +0200 Message-Id: <20210624205724.18711-3-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 3/3] avcodec/utils: Use 64bit for intermediate in AV_CODEC_ID_ADPCM_THP* duration calculation 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: O6XNJdj/pWqq Fixes: signed integer overflow: 486539264 * 14 cannot be represented in type 'int' Fixes: 35281/clusterfuzz-testcase-minimized-ffmpeg_dem_RSD_fuzzer-6068262742917120 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 342709353f..88e88bc958 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -712,7 +712,7 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, case AV_CODEC_ID_ADPCM_THP: case AV_CODEC_ID_ADPCM_THP_LE: if (extradata) - return frame_bytes * 14 / (8 * ch); + return frame_bytes * 14LL / (8 * ch); break; case AV_CODEC_ID_ADPCM_XA: return (frame_bytes / 128) * 224 / ch;