From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 9B2A344B5B for ; Thu, 14 Aug 2025 00:25:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id BCE7068D01D; Thu, 14 Aug 2025 03:25:48 +0300 (EEST) Received: from 1e8b7847f7d1 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id C37C368B18F for ; Thu, 14 Aug 2025 03:25:47 +0300 (EEST) MIME-Version: 1.0 From: michaelni To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] =?utf-8?q?=5BPATCH=5D_avutil/timecode=3A_Check_fo?= =?utf-8?q?r_integer_overflow_in_av=5Ftimecode=5Finit=5Ffrom=5Fcomponents?= =?utf-8?b?KCkgKFBSICMyMDIzNik=?= 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Message-Id: <20250814002548.BCE7068D01D@ffbox0-bg.ffmpeg.org> Date: Thu, 14 Aug 2025 03:25:48 +0300 (EEST) Archived-At: List-Archive: List-Post: PR #20236 opened by michaelni URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20236 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20236.patch Fixes: integer overflow Fixes: testcase that calls av_timecode_init_from_components() with hh set explicitly to INT_MAX Found-by: Youngjae Choi, Mingyoung Ban, Seunghoon Woo Signed-off-by: Michael Niedermayer >From 0762e660ff8fb8c2f4c3d46a6a6c821bd69633e6 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 14 Aug 2025 02:12:26 +0200 Subject: [PATCH] avutil/timecode: Check for integer overflow in av_timecode_init_from_components() Fixes: integer overflow Fixes: testcase that calls av_timecode_init_from_components() with hh set explicitly to INT_MAX Found-by: Youngjae Choi, Mingyoung Ban, Seunghoon Woo Signed-off-by: Michael Niedermayer --- libavutil/timecode.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavutil/timecode.c b/libavutil/timecode.c index bca16b6ac2..052c488071 100644 --- a/libavutil/timecode.c +++ b/libavutil/timecode.c @@ -211,6 +211,7 @@ int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start int av_timecode_init_from_components(AVTimecode *tc, AVRational rate, int flags, int hh, int mm, int ss, int ff, void *log_ctx) { int ret; + int64_t s; memset(tc, 0, sizeof(*tc)); tc->flags = flags; @@ -221,7 +222,15 @@ int av_timecode_init_from_components(AVTimecode *tc, AVRational rate, int flags, if (ret < 0) return ret; - tc->start = (hh*3600 + mm*60 + ss) * tc->fps + ff; + s = hh*3600LL + mm*60LL + ss; + if (s != (int32_t)s) + return AVERROR(EINVAL); + + s = s * tc->fps + ff; + if (s != (int32_t)s) + return AVERROR(EINVAL); + tc->start = s; + if (tc->flags & AV_TIMECODE_FLAG_DROPFRAME) { /* adjust frame number */ int tmins = 60*hh + mm; tc->start -= (tc->fps / 30 * 2) * (tmins - tmins/10); -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".