From patchwork Mon Aug 7 00:49:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 43153 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9329:b0:130:ccc6:6c4b with SMTP id r41csp1303236pzh; Sun, 6 Aug 2023 17:50:19 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFPImjVb5HNKDcr3bhEFwlkk5xszbJRh4jAwrAA8DZWV2lpUmdOwkfJjcqkwewIHjki9YM X-Received: by 2002:a17:906:32d9:b0:982:c69c:8c30 with SMTP id k25-20020a17090632d900b00982c69c8c30mr7090014ejk.55.1691369419493; Sun, 06 Aug 2023 17:50:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691369419; cv=none; d=google.com; s=arc-20160816; b=zgcJpGSOzkZVQFycOq4NVaQNlfB1p8Wqk+N8frM3emRh4RHrn9MU/6ELNErV9wDtoY TOqsGIqaEKhlpKfMqWnl2CxqVDf0b4r1v3e02C7uAmcIAR0MLKUrtPaEX75Uiu9W2WIR BW3Ly2zhFiBDaIWjOgPDY2SBp1X9qW4pB8AKj2wz8Kh515r0b/UvHg1OsTtM/hf6IDic IPfPjXcESyvKHMOhmOWWlLijsd0BOwHMw6Fn1XZQdCSbKQ5Iabfy5JqEKehOAV9oucMP pJVf9aKU7NtEjBB7RfNOhW5JPqSrFKFJpN9rSPG9WOAiEfifAHfOnGsgaSCNJYd69wFh V5Og== 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=jXlOFyYcjvS+lfo1RRCWdUJ4H2ks/6huUZjXRD3SaLA=; fh=YYwLYmpaV0Fpw/rxmSKNRLS2XzDkAlGbHATiKOPtZrY=; b=o9ZY49uOC8GCq0x82LxgGxa/wBuRLGqnF3vquBx5ddcOXMUzKofI+36BzVfnqnWjqx G/fzIPcIyomx3mNr+CaV0UpvqrEerfzy/YrXmHDUJc7umKUyPA310N2fxA9CctkyyGG1 Ny5ROyy65Z18dc6mEOwPanKNLSSpF8DYEZ90YqUaUnQ7jZR5PpPSqIaw12zbIgW61eqY F08HWYLHmxeFAM3ilZzGgQeJ0nOdpys1LAzdaHq8wlDufnrvXN9CTcaP2PLfMWowZmFl toVDkLOKcCbblc8LjJT4njUJOa0Fag483Psx/ELbQkOS6pEBM9yrSu56P8xHtA62pqD6 PD4w== 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 g13-20020a170906394d00b00997dfeb04a1si5267764eje.70.2023.08.06.17.50.19; Sun, 06 Aug 2023 17:50:19 -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 E216868C4FC; Mon, 7 Aug 2023 03:50:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6C44E688158 for ; Mon, 7 Aug 2023 03:49:53 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id A71ADFF804 for ; Mon, 7 Aug 2023 00:49:52 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 7 Aug 2023 02:49:47 +0200 Message-Id: <20230807004949.31634-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230807004949.31634-1-michael@niedermayer.cc> References: <20230807004949.31634-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/xvididct: Fix integer overflow in idct_row() 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: d5XlmVW8npbc Fixes: signed integer overflow: -1403461578 + -843974775 cannot be represented in type 'int' Fixes: 60868/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG1VIDEO_fuzzer-4599793035378688 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/xvididct.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libavcodec/xvididct.c b/libavcodec/xvididct.c index f338901ab2..43ea927437 100644 --- a/libavcodec/xvididct.c +++ b/libavcodec/xvididct.c @@ -69,24 +69,24 @@ static int idct_row(short *in, const int *const tab, int rnd) if (!(right | in[4])) { const int k = c4 * in[0] + rnd; if (left) { - const int a0 = k + c2 * in[2]; - const int a1 = k + c6 * in[2]; - const int a2 = k - c6 * in[2]; - const int a3 = k - c2 * in[2]; + const unsigned a0 = k + c2 * in[2]; + const unsigned a1 = k + c6 * in[2]; + const unsigned a2 = k - c6 * in[2]; + const unsigned a3 = k - c2 * in[2]; const int b0 = c1 * in[1] + c3 * in[3]; const int b1 = c3 * in[1] - c7 * in[3]; const int b2 = c5 * in[1] - c1 * in[3]; const int b3 = c7 * in[1] - c5 * in[3]; - in[0] = (a0 + b0) >> ROW_SHIFT; - in[1] = (a1 + b1) >> ROW_SHIFT; - in[2] = (a2 + b2) >> ROW_SHIFT; - in[3] = (a3 + b3) >> ROW_SHIFT; - in[4] = (a3 - b3) >> ROW_SHIFT; - in[5] = (a2 - b2) >> ROW_SHIFT; - in[6] = (a1 - b1) >> ROW_SHIFT; - in[7] = (a0 - b0) >> ROW_SHIFT; + in[0] = (int)(a0 + b0) >> ROW_SHIFT; + in[1] = (int)(a1 + b1) >> ROW_SHIFT; + in[2] = (int)(a2 + b2) >> ROW_SHIFT; + in[3] = (int)(a3 + b3) >> ROW_SHIFT; + in[4] = (int)(a3 - b3) >> ROW_SHIFT; + in[5] = (int)(a2 - b2) >> ROW_SHIFT; + in[6] = (int)(a1 - b1) >> ROW_SHIFT; + in[7] = (int)(a0 - b0) >> ROW_SHIFT; } else { const int a0 = k >> ROW_SHIFT; if (a0) {