From patchwork Thu May 25 21:40:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 41828 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp865188pzb; Thu, 25 May 2023 14:40:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6LV+UjkGSTKfJb7jlgzB4gyJMqatuN9rJheyYUWmh/LybDg/y0aqdjl2XvjJd6aJfbULtp X-Received: by 2002:a17:907:2688:b0:96f:7636:65ca with SMTP id bn8-20020a170907268800b0096f763665camr2576740ejc.3.1685050844450; Thu, 25 May 2023 14:40:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685050844; cv=none; d=google.com; s=arc-20160816; b=KolDzdbKpghyjVcnvdFip7YPW6Q1pJ0fm9U6u2nGKhv1OPmDxDNH422Altg0KM8p1S 0BRDtB0NRI8RQmqGw6QMGvLD+mC1o9baY2ORRduMQubA6nqMael0ZL/F1qAUD7ENAeWV jI5XubdrTDjHB7hdvMtdWxsAFjhNkTrYGgzsnyiHORy/xVq5FIkIGRuUBIaMTmta82AQ 1dzEt6UW/KMKJIHV0mUljUzb5yOoYu93pDoSGGnjb91aYqvlBhatQQ6fZqKFk91dFxIs OsSSxoy9A/lTrt3oGkI9qN+s/6wxNmWKIApOHzOYJ37ucv9OB8q7CRSucJmqH/NbVuJ1 qciw== 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=+1pIB/AO3OWWQ7SAururnDUfFea28jUWYk3BzKxA1vE=; b=uyrZOIQlkQdKOah41TuoXIYXkZ49scsXaDafdEPW6LW27o2hJxZUffDYu6GN/U3kbR 90sD2Oml0FFaUQc0QoUj8XXn3PqjMe1gQz15DffjEC0paOwOowFj238OywNNJ7FXF4gb +kK+fij2NfuAK5u2DccGV3NwZm2mrlLZCa6LkdOSArSwaSctwyt1VKmMZaQ73J9WHFgV w2X2Uc3h05orYMGJ3ea8SnjhHvovM9HjBMSdkOCFa8KLguyuixHTiwvQ+fGdav31qgPN /NZnEP/lJ2lVcMl3TDxE2jP5X07GM5Bfu1PM0/b6CrB6t1xiUjRPp4m3RyuqI601h5Vj JgLw== 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 fq2-20020a1709069d8200b00965ec09592bsi1494039ejc.817.2023.05.25.14.40.44; Thu, 25 May 2023 14:40:44 -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 618F168C1D4; Fri, 26 May 2023 00:40:29 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4118C68C13F for ; Fri, 26 May 2023 00:40:22 +0300 (EEST) X-GND-Sasl: michael@niedermayer.cc Received: by mail.gandi.net (Postfix) with ESMTPSA id 9900640004 for ; Thu, 25 May 2023 21:40:21 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 25 May 2023 23:40:16 +0200 Message-Id: <20230525214019.29048-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230525214019.29048-1-michael@niedermayer.cc> References: <20230525214019.29048-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/5] avcodec/takdsp: Fix integer overflows 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: eo8F7AZfWqg2 Fixes: avcodec/takdsp.c:44:23: runtime error: signed integer overflow: -2097158 - 2147012608 cannot be represented in type 'int' Fixes: 58417/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TAK_fuzzer-5268919664640000 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/takdsp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/takdsp.c b/libavcodec/takdsp.c index 881d7be5f2..b646a063db 100644 --- a/libavcodec/takdsp.c +++ b/libavcodec/takdsp.c @@ -28,8 +28,8 @@ static void decorrelate_ls(int32_t *p1, int32_t *p2, int length) int i; for (i = 0; i < length; i++) { - int32_t a = p1[i]; - int32_t b = p2[i]; + uint32_t a = p1[i]; + uint32_t b = p2[i]; p2[i] = a + b; } } @@ -39,8 +39,8 @@ static void decorrelate_sr(int32_t *p1, int32_t *p2, int length) int i; for (i = 0; i < length; i++) { - int32_t a = p1[i]; - int32_t b = p2[i]; + uint32_t a = p1[i]; + uint32_t b = p2[i]; p1[i] = b - a; } } @@ -50,7 +50,7 @@ static void decorrelate_sm(int32_t *p1, int32_t *p2, int length) int i; for (i = 0; i < length; i++) { - int32_t a = p1[i]; + uint32_t a = p1[i]; int32_t b = p2[i]; a -= b >> 1; p1[i] = a; @@ -63,7 +63,7 @@ static void decorrelate_sf(int32_t *p1, int32_t *p2, int length, int dshift, int int i; for (i = 0; i < length; i++) { - int32_t a = p1[i]; + uint32_t a = p1[i]; int32_t b = p2[i]; b = (unsigned)((int)(dfactor * (unsigned)(b >> dshift) + 128) >> 8) << dshift; p1[i] = b - a;