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 E96394B30D for ; Tue, 9 Jul 2024 18:34:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7653D68DBB3; Tue, 9 Jul 2024 21:34:49 +0300 (EEST) Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B6BD868D8AE for ; Tue, 9 Jul 2024 21:34:43 +0300 (EEST) Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-444fdb6c1cfso36234021cf.3 for ; Tue, 09 Jul 2024 11:34:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720550082; x=1721154882; 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=ovtSpuYfadBy9Mi94HgwoftBKFmnhJMDTRXZr8SS0W4=; b=dQhJGr0azU5KwfXOs+c0AGkZ3ZiagILJyACecqdZKwx/Qt9NctVEdp9zBVJT+HKSFr /smsHu7ErhGJ4+hB+Nq3fQ+tknQjMqY4f+FpKaXSs0svcUEq5vlnfOJ9bUqSxJs7MWrP nLJI4JtxUxlX2KMx08faO5AAiQ2whuHoNR6vdvc5Fv+3bSvIdkHBPhAhTzseUKhi9+qN AsUnRkF8DtSWI9ekPhCOvdBa2wyMOM+SkMifhyLiBue8/IGvMpn5al2j8JXSbuHCJ+gL O85HzJxgDLdC3RtbfSHt35ElmOVCCmq+YGwStWWib8jRHR6cn3tHNp7P+xcxHRaLOYuX c0gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720550082; x=1721154882; 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=ovtSpuYfadBy9Mi94HgwoftBKFmnhJMDTRXZr8SS0W4=; b=Nqbld+r8WJofFjGw0hhntPhIpVxuuU6EbMWk85obimqlwzCdH0L1eyFSVgUzHu6rCU ag8t7XXBBP4jeseNFAx7yzE/MI874vMeLgf8ATcNgKP5UAXsRMv+9uJBIX37RZyJ1R1B TPhSybibpi4P+m9Mvzal2p0OVSgO3gJl9z+Nto3va9M4wtsHY4+FfpaKRGdoYl+m5hXs YLocrtQhEuxKuvtfM3FnzazzbKsc9+krHr93AH5OBjUy7L7RGGLXNBIe929pt/2BXsrX BnPpXFnOPCbiqmxa2ryZLWxCWL0IocqKym6Z8miOY+6YpcxYFTg5SBool3HwfvmfuuH5 md6w== X-Gm-Message-State: AOJu0YyP8cawDtegCXg+S7oIvn55ob/ZUAMn4lA4AKhmyFgVX2xLT9K4 JpJIwVqyVIa2gk6T9zSTFADLdnKziITmsfZEvJDVtQyHfeB8Yye1lIxUXA== X-Google-Smtp-Source: AGHT+IED4Ai/lLAfB+oiKNnbmrfyhlxvq0Z19UPVM+9FqTlDoLjCHiR75cPlOmn1SRExarvCAC/o4w== X-Received: by 2002:a05:6214:5015:b0:6b0:90d8:b698 with SMTP id 6a1803df08f44-6b61c1b5ac0mr47720486d6.45.1720550081578; Tue, 09 Jul 2024 11:34:41 -0700 (PDT) Received: from haruno.seanmcgovern.ca ([2607:f2c0:929e:a300:5a14:889f:e8c4:9ee4]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b61baa24efsm10870636d6.142.2024.07.09.11.34.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 11:34:39 -0700 (PDT) From: Sean McGovern To: ffmpeg-devel@ffmpeg.org Date: Tue, 9 Jul 2024 14:34:34 -0400 Message-Id: <20240709183434.10114-1-gseanmcg@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240708042517.5585-1-gseanmcg@gmail.com> References: <20240708042517.5585-1-gseanmcg@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCHv3] 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', 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 int32_t. --- libswscale/yuv2rgb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c index 977eb3a7dd..ac0b811f61 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] + ((int32_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] + ((int32_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".