From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id B19F64576A for ; Mon, 20 Feb 2023 19:29:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9398E68C096; Mon, 20 Feb 2023 21:29:43 +0200 (EET) Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 534E268C091 for ; Mon, 20 Feb 2023 21:29:36 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 6071A240006 for ; Mon, 20 Feb 2023 19:29:35 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 20 Feb 2023 20:29:26 +0100 Message-Id: <20230220192929.4493-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230220192929.4493-1-michael@niedermayer.cc> References: <20230220192929.4493-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/6] avcodec/rka: Fix some integer anomalies 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Fixes: left shift of negative value -3201 Fixes: integer overflow: -76470276 * -25608 cannot be represented in type 'int' Fixes: 56052/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RKA_fuzzer-5236218750435328 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/rka.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/rka.c b/libavcodec/rka.c index 461baf1e1f..994c563ffd 100644 --- a/libavcodec/rka.c +++ b/libavcodec/rka.c @@ -723,16 +723,16 @@ static int decode_filter(RKAContext *s, ChContext *ctx, ACoder *ac, int off, uns last_val = val; src = &ctx->buf1[off + -1]; for (int i = 0; i < filt.size && i < 15; i++) - sum += filt.coeffs[i] * src[-i]; + sum += filt.coeffs[i] * (unsigned)src[-i]; sum = sum * 2; for (int i = 15; i < filt.size; i++) - sum += filt.coeffs[i] * src[-i]; + sum += filt.coeffs[i] * (unsigned)src[-i]; sum = sum >> 6; if (ctx->cmode == 0) { if (bits == 0) { ctx->buf1[off] = sum + val; } else { - ctx->buf1[off] = (val + (sum >> bits) << bits) + + ctx->buf1[off] = (val + (sum >> bits)) * (1 << bits) + (((1U << bits) - 1U) & ctx->buf1[off + -1]); } ctx->buf0[off] = ctx->buf1[off] + ctx->buf0[off + -1]; -- 2.17.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".