From patchwork Sun Sep 18 17:13:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 38009 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp790849pzh; Sun, 18 Sep 2022 10:14:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4OXpZ4FB5gdOHHc6Lq/1ML/IYEWKmu70KTv/OIzu1Eiuk/5dBnZp5hLr2skZOzX2CT/64N X-Received: by 2002:a05:6402:1d84:b0:44e:8158:84 with SMTP id dk4-20020a0564021d8400b0044e81580084mr12081921edb.80.1663521289839; Sun, 18 Sep 2022 10:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663521289; cv=none; d=google.com; s=arc-20160816; b=e7sFWNfpUmxju+VmUxmstE6zUQMzgs9XQL9vhwUzk8xN/6jorbLGJtcGjF6HkS8eQ6 2T+PDn/r/9pY4nUZhk+C0WIcK/4h/jQxXCMGuTXq96cANlPcO00kfIkHQzWYcJAT9NzO YdowYzCOWZ8vW2d4exIxXBOWeTZ2vMiGOcqDw7UYxBxlWCSD5+scH4SlBYkkf6AzkgZ1 qNAgg+WK1RPYop3vaW9WeR2SVaISpMrAqEg2P23GVpbt1ZKs2ZWJ9beGDht90SMXgHDb UqGma7TazNiqrevhA3ammaFRrt9dzN1Px4dNqzwYX0hwTzaQH8TuOsLWE0nYJJZiBo1c 51WA== 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=3jIw3XLJ8iLxJnL4+6Q4V7rJQW/liU4H0Dunc5Yo2TE=; b=EB5xU8uIEzyMsiYf879k46/Wyyq9aiTZiLjYHaT05+TJ5uhTyiYRYkxz5kHnaLoZ8K zqiiZ6RILf00fK+9D9nzuKtPtewT9ZH4USwhRCS5BUDt/nQcvXvtbmza5Qh5xhQg1SZm NadL5J1aykuh53YcLuJZ42uCJ0ZqbkVALmBvEkT/0xzsUaha6KL7wawF2JgaBqJa20Nd GweACHioYakiHBpbsuX6qlcfbzyB5CqG9NzCSfGo1Gk9orV7rWZtwEyZt/XDqUjaygHe ADL/R2FrTWtcSUFKgdwUtpw+2YXP0JGaESXLn8ebNiZOC+Bq8ah2nsX6Bw6ccc2DIufv YdQA== 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 j15-20020a508a8f000000b0044e762b8d4bsi7550249edj.480.2022.09.18.10.14.49; Sun, 18 Sep 2022 10:14:49 -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 56E4C68BB9B; Sun, 18 Sep 2022 20:14:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-at02-1.mx.upcmail.net (vie01a-dmta-at02-1.mx.upcmail.net [62.179.121.148]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3392268BB14 for ; Sun, 18 Sep 2022 20:14:13 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-at02.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1oZxrv-0047Wn-Dv for ffmpeg-devel@ffmpeg.org; Sun, 18 Sep 2022 19:14:11 +0200 Received: from ren-mail-psmtp-mg02. ([80.109.253.241]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id Zxruom0288s8UZxruoH66v; Sun, 18 Sep 2022 19:14:11 +0200 Received: from localhost ([213.47.68.29]) by ren-mail-psmtp-mg02. with ESMTP id Zxruo4SrvbZLDZxruoJKI6; Sun, 18 Sep 2022 19:14:10 +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.4 cv=Ufwy9IeN c=1 sm=1 tr=0 ts=632751e2 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=NEAV23lmAAAA:8 a=5rNS-B3umHXH4wTWp8IA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 18 Sep 2022 19:13:58 +0200 Message-Id: <20220918171410.31835-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4wfI9BV6yW0sx0oIBpYi4B7nmO8jtIIvYg6+aaFCJvkg6q+J8GgAYuIUbMETmjcEj+HYJ22eiYe3zZSDb/idM2zHXZUBiEBgWtRETUdhnbXxpxlxXGDzZf 1O0kz+Fkpc1auDMkHd/G1b/Bv1eqgmmTJQudyl+OF7BNPDjXNth7HHDCvA8eHFgVjlr0xO3FW3WJnA== Subject: [FFmpeg-devel] [PATCH 01/13] avformat/flvdec: Use 64bit for sum_flv_tag_size 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: GjfOd5cndQMT Fixes: signed integer overflow: 2138820085 + 16130322 cannot be represented in type 'int' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_LIVE_FLV_fuzzer-6704728165187584 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/flvdec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c index 7f9d7950448..d83edff727c 100644 --- a/libavformat/flvdec.c +++ b/libavformat/flvdec.c @@ -66,7 +66,7 @@ typedef struct FLVContext { uint8_t resync_buffer[2*RESYNC_BUFFER_SIZE]; int broken_sizes; - int sum_flv_tag_size; + int64_t sum_flv_tag_size; int last_keyframe_stream_index; int keyframe_count; @@ -1032,7 +1032,7 @@ retry: type = (avio_r8(s->pb) & 0x1F); orig_size = size = avio_rb24(s->pb); - flv->sum_flv_tag_size += size + 11; + flv->sum_flv_tag_size += size + 11LL; dts = avio_rb24(s->pb); dts |= (unsigned)avio_r8(s->pb) << 24; av_log(s, AV_LOG_TRACE, "type:%d, size:%d, last:%d, dts:%"PRId64" pos:%"PRId64"\n", type, size, last, dts, avio_tell(s->pb)); @@ -1332,7 +1332,7 @@ leave: !avio_feof(s->pb) && (last != orig_size || !last) && last != flv->sum_flv_tag_size && !flv->broken_sizes) { - av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d %d\n", last, orig_size + 11, flv->sum_flv_tag_size); + av_log(s, AV_LOG_ERROR, "Packet mismatch %d %d %"PRId64"\n", last, orig_size + 11, flv->sum_flv_tag_size); avio_seek(s->pb, pos + 1, SEEK_SET); ret = resync(s); av_packet_unref(pkt);