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 0D72B4BA12 for ; Tue, 9 Jul 2024 21:41:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BD02068DB65; Wed, 10 Jul 2024 00:41:47 +0300 (EEST) Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1BE3E68DA13 for ; Wed, 10 Jul 2024 00:41:41 +0300 (EEST) Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-79f178351d4so132433985a.0 for ; Tue, 09 Jul 2024 14:41:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720561299; x=1721166099; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=6U69t/zLjVwVG0rNsd4T1rBTuo+CBIaWrOSkMHvTvGc=; b=g4CcrrezndfQe29hVRBLYs8vUKDR+oBT8HBvTJr7qOIwze82lx7FrJQm/iDBWUgu9i bKRO7bhW00gzBo3Yq66zKdu/5eCc4LXUItInKrF4h+yhLxYkBCb7SgTHmSfB8e7Wlx3n oCyR7qg82047UtUggX46jbms6a4fXi5RxVVQK8gBgy3DyXEX/yL7kw418UypwHzmtMtc /WGBIL6HMth9skjNqkqBs1+n1WP078zqZCjv3OqNKf4DMH2JGQuXtqaFNARW2LGyoMuU niKC2UPINT6kMqybFGzn9yZShh7Q1ja9oj36IBodBSiCZH/cVli6WSYOI5b64ojgND8x W6hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720561299; x=1721166099; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6U69t/zLjVwVG0rNsd4T1rBTuo+CBIaWrOSkMHvTvGc=; b=luzuy8QWxZuSx1GzBnpxdrHDslasoQ6ibeuVK9UuwZ04NpMQ0pMfHG6ku6TJwO0xE3 yBwTujCXOWhzJvAR+lm1KdvV7axeInfr+gRKCeysqtHth60MefQwlmr5vw+H8/GF/T9E BZHJsw0jtU7EhnjQ78VF2IWb25RHCCd5QazatvUpUv5gdB358w408dprHTnuYIMaWJkZ nVhuktvUUmnEFtnaNxMGgqetskg+qgTTD6TDDBJSE2AZMSWrf2/6qnfN5spPWfGYjz+O j8uNQJs2Zn/iE1EhOtutVlB3v8NVOdSFPNjPawMmIKAAOkrVobwQA4d5k3Ds0phZtkRk r06w== X-Gm-Message-State: AOJu0YyYsyOWcHlbPxBqHGhF6UbATBs2sONnmCEP0ja2TAn0BlWl+bm7 fPj6OS/SFLQnx1Eg6/yyuW0QHAVzmqEXSBl7FWobdiQNHxgo1BBfFQdG9w== X-Google-Smtp-Source: AGHT+IGNgZTTSzOm+dq71HelpECvrO2NLMKlQFafi8a6M4Kv1INuJE4mTiu1wsO+iIjF6Y+fzlntKA== X-Received: by 2002:a05:620a:5802:b0:79f:b60:bc28 with SMTP id af79cd13be357-79f19a6ebfbmr414403485a.23.1720561298981; Tue, 09 Jul 2024 14:41:38 -0700 (PDT) Received: from haruno.seanmcgovern.ca (pool-174-116-53-158.cpe.net.cable.rogers.com. [174.116.53.158]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79f1902b956sm135024485a.68.2024.07.09.14.41.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 14:41:38 -0700 (PDT) From: Sean McGovern To: ffmpeg-devel@ffmpeg.org Date: Tue, 9 Jul 2024 17:41:32 -0400 Message-Id: <20240709214132.12016-1-gseanmcg@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240709183434.10114-1-gseanmcg@gmail.com> References: <20240709183434.10114-1-gseanmcg@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCHv4] swscale: prevent undefined behaviour in the PUTRGBA macro 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 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: For even small values of 'asrc[x]', shifting them by 24 bits or more will cause arithmetic overflow and be caught by GCC's undefined behaviour sanitizer. Ensure the values do not overflow by up-casting the bracketed expressions involving 'asrc' to uint32_t. --- libswscale/yuv2rgb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index 977eb3a7dd..cfbc54abd0 100644 --- a/libswscale/yuv2rgb.c +++ b/libswscale/yuv2rgb.c @@ -100,9 +100,9 @@ const int *sws_getCoefficients(int colorspace) #define PUTRGBA(dst, ysrc, asrc, i, abase) \ Y = ysrc[2 * i]; \ - dst[2 * i] = r[Y] + g[Y] + b[Y] + (asrc[2 * i] << abase); \ + dst[2 * i] = r[Y] + g[Y] + b[Y] + ((uint32_t)(asrc[2 * i]) << abase); \ Y = ysrc[2 * i + 1]; \ - dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + (asrc[2 * i + 1] << abase); + dst[2 * i + 1] = r[Y] + g[Y] + b[Y] + ((uint32_t)(asrc[2 * i + 1]) << abase); #define PUTRGB48(dst, src, asrc, i, abase) \ Y = src[ 2 * i]; \ -- 2.39.2 _______________________________________________ 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".