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 4A4084EB0C for ; Sun, 15 Feb 2026 14:02:15 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'P18PuXfv31LIW7tBUgczqnD9liOeyilai442uQ7uG/s=', expected b'D9OCGb9hEABcU9Z4Y97QuADJElJr2KCdJNd/wMA3eVE=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771164123; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=P18PuXfv31LIW7tBUgczqnD9liOeyilai442uQ7uG/s=; b=mGt8XgN3zlM9JfpTBnfD8MROveMfrvq4cfk5Tut50ezc2GI4o/xpyEEKRe986hcoXH/FP uOuWt4bkC1C8cE7dDwH8B3mk+rygCY8TK9ONHuJRDKggofEBQ9NAKpmO2wIhc9mpeYmOU4n t3X1+oQbPpd4gMmFxXrRT77cG7wjxYAoiSSJchWTRCYe9LoUtqgkCZXsZoaUb+AtbZnsYX3 iHMWRrNu8I8pgflrzCzkrG0yLxM/82ClX2z6g4Fqilb//Jox1abT2VVImHkG6hwBohXUQJv s5nqRhUPLFrhOCxxAGItqKxM2I6SumYJowtdVv9fPM3RzsrM0UWsx50TIdXw== Received: from [172.20.0.3] (unknown [172.20.0.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id D0D66691215; Sun, 15 Feb 2026 16:02:03 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1771164115; b=HQESttecBFH44ldRYatHgstlu+f4Bobc+RKpLimXdUsAMQxMCNICd544ZVimQGM3Ewh8P Bd4bABM0tOsjpKWv4Y3H0PPD05+xpw+3oJ+HSYleWs5LG5bCJmyQKErxcDWsqjWYXNbpmTl uZW6HtzdMOVf8DJAW5xSP8AZVRp+sbD6247jnLsF/P/2yGLrLm0XlgQX0t4kk1ya7D03V2P XTSVe+OgXqsUZerjGQglOZiYy9qWCVqyzJDbt3QxRDBwsmZifd5JdLlyJ70HzhyFVraEnep NC7OFgdNj4221TiwRx1WKlNX8t8uszCHsQYjCoMX708lmk6zvwEFwCqq5HNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1771164115; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=OJQU/snHcJMTJQRwnqtfL51V7LduXv5PS8W5ZlKfan8=; b=X1/KA9b2vcLY3v6lYF2IlQf1mzbLM0L9oZLrA5VSLkmjPZ47CQQaA7+CzDulnEfkeKgnR 2t+RnHk75UiqJOINm9kCWeCKJkeFfXbfanZuLz81uuvWRZxAvzS/+HcK6r6M/4xK//IqRJ7 vL5I1kjZOPn3oD1OXFyqesuzR/6MvnHFzqaJF7N3cTdbcENFz5HBVm/cFKNCHVoFn5g3KEl xZKyajSf5EtWFh6S1CF6stX7dT5W/3+DNTgexhldlK/ojTYRNU4EbReBzczspHYaa1jqH7x uURlyHm3ITVEQMeIpz7bbhGnc9Vfwme6guI8XbAn4wNAHloXqZGzya0TVFgw== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1771164109; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=D9OCGb9hEABcU9Z4Y97QuADJElJr2KCdJNd/wMA3eVE=; b=A3zX2tU7PvEkanWUtRqpacajmujhIlfQpRu9VeCkA9q15v+rSs52nv56GFSsFt/nvGRto b5dyQ3MJWx07w6bQ2I/pqcDy8k7C8kXGTIgeWVDc5P0NujF1PaHswEXbRTIXkclhMsEvZKZ UcujCdyIH0lUUFmzXDALnO1n6Z2XYlimxFmRvhcFM6RI55Fmct5I5G/f72xSi/uAXsw+lqn kpoJLqS8Jdz4o2cXtkBFRZyOKDN8GPkAAfo/Pz/MRkf865GAjFN+s9NWfEnv5ezsLQFLaRQ CJPjahcFh3ehL7SS3/1ACVfEM/gSaivI3Vwx6FNZ41QlBItuzg8Hfb1SlnbQ== Received: from c8d966988b92 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 990AD691207 for ; Sun, 15 Feb 2026 16:01:49 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Sun, 15 Feb 2026 14:01:49 -0000 Message-ID: <177116410971.25.8246123649711188102@009cbcb3d8cd> Message-ID-Hash: CFABXSFQHKAEX4ENXBLA3HUMNDB7RC7L X-Message-ID-Hash: CFABXSFQHKAEX4ENXBLA3HUMNDB7RC7L X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PR] swresample/resample_template: add casts to avoid undefined overflows (PR #21764) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: michaelni via ffmpeg-devel Cc: michaelni Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21764 opened by michaelni URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21764 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21764.patch resample_linear can produce overflows with craftet input, The added casts should have no effect on the binary output or the operations they just change things to a defined regime Fixes: signed integer overflow: 2069416960 + 78151680 cannot be represented in type 'int' Fixes: 472047214/clusterfuzz-testcase-minimized-ffmpeg_SWR_fuzzer-6374046976770048 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer >>From 4e0ece554b889ae4c20ae3acd01df3bec099de10 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 15 Feb 2026 02:18:01 +0100 Subject: [PATCH] swresample/resample_template: add casts to avoid undefined overflows resample_linear can produce overflows with craftet input, The added casts should have no effect on the binary output or the operations they just change things to a defined regime Fixes: signed integer overflow: 2069416960 + 78151680 cannot be represented in type 'int' Fixes: 472047214/clusterfuzz-testcase-minimized-ffmpeg_SWR_fuzzer-6374046976770048 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libswresample/resample_template.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libswresample/resample_template.c b/libswresample/resample_template.c index 4c227b9940..c6cc55e7ad 100644 --- a/libswresample/resample_template.c +++ b/libswresample/resample_template.c @@ -25,6 +25,8 @@ * @author Michael Niedermayer */ +// FELEM2U, a variant of FELEM2 which does not produce undefined overflow + #if defined(TEMPLATE_RESAMPLE_DBL) # define RENAME(N) N ## _double @@ -32,6 +34,7 @@ # define DELEM double # define FELEM double # define FELEM2 double +# define FELEM2U double # define FOFFSET 0 # define OUT(d, v) d = v @@ -42,6 +45,7 @@ # define DELEM float # define FELEM float # define FELEM2 float +# define FELEM2U float # define FOFFSET 0 # define OUT(d, v) d = v @@ -52,6 +56,7 @@ # define DELEM int32_t # define FELEM int32_t # define FELEM2 int64_t +# define FELEM2U uint64_t # define FELEM_MAX INT32_MAX # define FELEM_MIN INT32_MIN # define FOFFSET (1<<(FILTER_SHIFT-1)) @@ -64,6 +69,7 @@ # define DELEM int16_t # define FELEM int16_t # define FELEM2 int32_t +# define FELEM2U uint32_t # define FELEML int64_t # define FELEM_MAX INT16_MAX # define FELEM_MIN INT16_MIN @@ -161,7 +167,7 @@ static int RENAME(resample_linear)(ResampleContext *c, for (dst_index = 0; dst_index < n; dst_index++) { FELEM *filter = ((FELEM *) c->filter_bank) + c->filter_alloc * index; - FELEM2 val = FOFFSET, v2 = FOFFSET; + FELEM2U val = FOFFSET, v2 = FOFFSET; int i; for (i = 0; i < c->filter_length; i++) { @@ -169,15 +175,15 @@ static int RENAME(resample_linear)(ResampleContext *c, v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_alloc]; } #ifdef FELEML - val += (v2 - val) * (FELEML) frac / c->src_incr; + val += (FELEM2)(v2 - val) * (FELEML) frac / c->src_incr; #else # if FILTER_SHIFT == 0 - val += (v2 - val) * inv_src_incr * frac; + val += (FELEM2)(v2 - val) * inv_src_incr * frac; # else - val += (v2 - val) / c->src_incr * frac; + val += (FELEM2)(v2 - val) / c->src_incr * frac; # endif #endif - OUT(dst[dst_index], val); + OUT(dst[dst_index], (FELEM2)val); frac += c->dst_incr_mod; index += c->dst_incr_div; @@ -205,6 +211,7 @@ static int RENAME(resample_linear)(ResampleContext *c, #undef DELEM #undef FELEM #undef FELEM2 +#undef FELEM2U #undef FELEML #undef FELEM_MAX #undef FELEM_MIN -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org