From patchwork Sat Sep 30 22:30:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44069 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1204:b0:15d:8365:d4b8 with SMTP id v4csp599042pzf; Sat, 30 Sep 2023 15:32:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGGrdqlyJ9lB8GO2lk4zZMkZgkLRFrbcaF+vxx7spFFLopjUsDU122r3jAS/dSsDBh2xvI X-Received: by 2002:a17:906:2249:b0:9a3:faf:7aaa with SMTP id 9-20020a170906224900b009a30faf7aaamr6593170ejr.15.1696113125014; Sat, 30 Sep 2023 15:32:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696113125; cv=none; d=google.com; s=arc-20160816; b=0Ixec0g+77PgzVudTcubkGfZphkG9iRK1chWKhiQlMG6kfWlQD4hGv4R4ZPQCKQ5RW xN8zZYtflQO0Mgr+ac3bpzbjPZe32RMiMBE2ojITXdNylXS2ZpBNrDHqkL+acRDkbi+r epF2EGIe77rQFZU28KYmPFaA8FY00izCflis9kPPncmXDk6nScbGrLnEWFo5Eeq60gNf 1igOqe5fOSxavOwKAyPnracotx9BrmrHcZHKE1FjP7PVmChlX7+31cVhsnXb6r2OV77N GJBaaedKXquXBBty9U2EQNEjIDHuERPyUhEKMTawZEzbVhMwvnGLPEjrbPg/Yn9jM6Lk We2A== 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=SX++90ZUeNEYKf8Oh5uSMqDHTD7nWg4P68w5+5maWh0=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=o/v69joOp7JOnra1x/jwgVEuAsEUAt5b3T7I0zeQNE+3h338Urs9kOGhJBs6xylkYR wKEkk+ZICRz2fDby6WwlFdAg7ebNYMClJZGrSF5f6fwZYJBSOcRAC4abGnN2uT2y8nxt xvU+cVIQk33Lhj7x0kk+zVu2p2GIwLKLsdseZo+ckUa9mWpIQ7z/9fUQQ7fGwU39Lk9K 1bml3Lv8T+fx+QoipRU6fonV4eIqjC8lJSp8pVNJsyhhp0GdHBLpj2y4aXy3DzAgv64+ YKgO/jD0zTJeBowdwR6aPvEgTPIESQfCeE+nmdDGLX2F4J6vQ5NNKVtJYnSAn3+ibY2b HrYA== 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 o20-20020a170906775400b0099cb1ff44bcsi17193025ejn.613.2023.09.30.15.32.04; Sat, 30 Sep 2023 15:32:04 -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 C7BA068CD7C; Sun, 1 Oct 2023 01:31:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 513BF68CD5E for ; Sun, 1 Oct 2023 01:30:54 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 978C11BF206 for ; Sat, 30 Sep 2023 22:30:53 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 1 Oct 2023 00:30:38 +0200 Message-Id: <20230930223046.22896-7-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230930223046.22896-1-michael@niedermayer.cc> References: <20230930223046.22896-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 07/15] avformat/sbgdec: Check for period 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: LPsgcL0pmvKQ Fixes: signed integer overflow: 4481246996173000000 - -4778576820000000000 cannot be represented in type 'long' Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-5063670588899328 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/sbgdec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c index c1995759a8f..73b5be9007d 100644 --- a/libavformat/sbgdec.c +++ b/libavformat/sbgdec.c @@ -1273,7 +1273,10 @@ static int generate_intervals(void *log, struct sbg_script *s, int sample_rate, /* SBaGen handles the time before and after the extremal events, and the corresponding transitions, as if the sequence were cyclic with a 24-hours period. */ - period = s->events[s->nb_events - 1].ts - s->events[0].ts; + period = s->events[s->nb_events - 1].ts - (uint64_t)s->events[0].ts; + if (period < 0) + return AVERROR_INVALIDDATA; + period = (period + (DAY_TS - 1)) / DAY_TS * DAY_TS; period = FFMAX(period, DAY_TS);