From patchwork Sun Jun 16 07:48:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 49939 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9196:0:b0:460:55fa:d5ed with SMTP id s22csp1284275vqg; Sun, 16 Jun 2024 00:48:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXPdsBN8pupPedNZ4PtzjGNrtvUi9ipuYa1gk8SAnhmBqD/TGD6xXYLfIF3WKGh4n5dypCKiCTLSqg8GA5jGXJRAd7QE6M4eqAVOg== X-Google-Smtp-Source: AGHT+IGI66lLTUoT/YRQYM646/++kZaIiVLFx9ZYpMan4/ztwprEkNyx5MiSDIPNeeUk1ITWZ0Qh X-Received: by 2002:a17:906:e86:b0:a6f:3ba9:9514 with SMTP id a640c23a62f3a-a6f60d3c082mr392529566b.37.1718524135575; Sun, 16 Jun 2024 00:48:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1718524135; cv=none; d=google.com; s=arc-20160816; b=mRwyehRsqks3/c8P+rlJJaWiAyxg59fTxFlQH63dFoM/DcuFMPj2TxM3ZK1HVILxS/ Q9RZiOyqXld2vvHW1Io5OHvY5s5igR8xREXW2v8RxJpwwM6ukSsZ33BOxfrZpQZRmLLo ErlO51tKqapKCbJIB3NzAgckRMwce5u4QWb6K2uzctJm/Y74XtWWfNBe5h1jLjHWe7Jp SH39011HLeCpHhsZ0VqEnmdCX4w+4JyTo2gsZc/1EAycGuhGoVUqCtguGGrr8yfaN4Wf EYe9OjWA/N4Bh34Gxk2ncvBZljMCKQSn46gvyOiPLi6NwQukoM7z/gRK4CWWue/USo4o iNJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=H9j1gccGFH9PXdlzUOtE7dWCJ/v/LshGQcqXfMp/nTU=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=zVzV5BZVSMooUKT4C4Wue4+QWhJTD7DkS8VWFbyPPv44tk24OFgjyUPexE3YGbD8Vh lNgohL5DF6oXuAcwpw7pKaa5fYp47RAlyrXVuU4VqJ3Uu3JXX6kU/I5fp8Q5GGTbylot evXmj37OzSTq/D5InmKnC8OQeZduFoyI0BKn52IMgtbcC+SyFF+HkdtED4WZccvVTkBq e97g0Yxfq0UG1Dn4tSXJhZCVOhV/GO0HVU8aqd24vuJjT2SrNef/lYdCt/tlu58gRkLr ZOdoTWKquO/TitB3glvmESdMMLOWQ0OS88Wd7RGgeroD18Ij6iYwDFa6wNIhW/dIQpEU ILnQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b="T3NQs8U/"; 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 a640c23a62f3a-a6f56d4d27esi349115766b.259.2024.06.16.00.48.55; Sun, 16 Jun 2024 00:48:55 -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; dkim=neutral (body hash did not verify) header.i=@niedermayer.cc header.s=gm1 header.b="T3NQs8U/"; 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 8E20F68D6B6; Sun, 16 Jun 2024 10:48:41 +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 1092E68D5D6 for ; Sun, 16 Jun 2024 10:48:34 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 418EC1BF205 for ; Sun, 16 Jun 2024 07:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1718524113; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8jMK0gj+sgHKdgZSBWsg7yGe/wM8sqJGARY4cUTHgAM=; b=T3NQs8U/b4b5w0MsIkCouP6EH29xLA9D2yxjLqfFnLCAtGf+5X8783nwdezqARFDJH/DqM wL30qs5XuFBcdIakHAibY/99AwbMs1rO8zXxc8RKtDuKoU4ac00hG2C9q9Vk2qhm5H1zoA ro9KD91I7ZRLvUDgfIcRtYTIxR19J17YKfa/rFeZn7NVuAmRapI2h+vg/P5CfuH3LRzgRU WD8ZByCt9ijdr1cHXvnlhycJXGOACtr0vkaTgMA6fBbct+IwKzwYW9MrnXL0h/IWmZjG4b MDWmrBR/OlPoGyl1EA4+HhWuRw1HSLHfYXIImVjOcRvcC4BnmfY+Snr1dUR1rw== From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 16 Jun 2024 09:48:31 +0200 Message-ID: <20240616074831.339149-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240616074831.339149-1-michael@niedermayer.cc> References: <20240616074831.339149-1-michael@niedermayer.cc> MIME-Version: 1.0 X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 2/2] swscale/output: Avoid undefined overflow in yuv2rgb_write_full() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: CVUSRGlGxgQt Fixes: signed integer overflow: -140140 * 16525 cannot be represented in type 'int' Fixes: 68859/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-4516387130245120 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libswscale/output.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libswscale/output.c b/libswscale/output.c index f9ce43dde80..0e6181b3e01 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -1925,9 +1925,9 @@ static av_always_inline void yuv2rgb_write_full(SwsContext *c, Y -= c->yuv2rgb_y_offset; Y *= c->yuv2rgb_y_coeff; Y += 1 << 21; - R = (unsigned)Y + V*c->yuv2rgb_v2r_coeff; - G = (unsigned)Y + V*c->yuv2rgb_v2g_coeff + U*c->yuv2rgb_u2g_coeff; - B = (unsigned)Y + U*c->yuv2rgb_u2b_coeff; + R = (unsigned)Y + V*(unsigned)c->yuv2rgb_v2r_coeff; + G = (unsigned)Y + V*(unsigned)c->yuv2rgb_v2g_coeff + U*(unsigned)c->yuv2rgb_u2g_coeff; + B = (unsigned)Y + U*(unsigned)c->yuv2rgb_u2b_coeff; if ((R | G | B) & 0xC0000000) { R = av_clip_uintp2(R, 30); G = av_clip_uintp2(G, 30);