From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 8EBF615800A for ; Tue, 25 Jul 2023 09:04:59 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BE8CCE0900; Tue, 25 Jul 2023 09:04:58 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 7DDA7E0900 for ; Tue, 25 Jul 2023 09:04:58 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 87FD3341521 for ; Tue, 25 Jul 2023 09:04:57 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id CEE4BDCA for ; Tue, 25 Jul 2023 09:04:55 +0000 (UTC) From: "Andreas Sturmlechner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Andreas Sturmlechner" Message-ID: <1690275887.e22db0940a068cc4c0e137d3e8247b368a5c8734.asturm@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: kde-frameworks/kimageformats/, kde-frameworks/kimageformats/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: kde-frameworks/kimageformats/files/kimageformats-5.108.0-psd-fix-UB-type-punning.patch kde-frameworks/kimageformats/kimageformats-5.108.0-r1.ebuild X-VCS-Directories: kde-frameworks/kimageformats/files/ kde-frameworks/kimageformats/ X-VCS-Committer: asturm X-VCS-Committer-Name: Andreas Sturmlechner X-VCS-Revision: e22db0940a068cc4c0e137d3e8247b368a5c8734 X-VCS-Branch: master Date: Tue, 25 Jul 2023 09:04:55 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: cfb73100-30ba-41fc-9400-9a9a901db4de X-Archives-Hash: d0888ae6b1780c7cb746f050a259e4fa commit: e22db0940a068cc4c0e137d3e8247b368a5c8734 Author: Andreas Sturmlechner gentoo org> AuthorDate: Tue Jul 25 08:52:40 2023 +0000 Commit: Andreas Sturmlechner gentoo org> CommitDate: Tue Jul 25 09:04:47 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e22db094 kde-frameworks/kimageformats: psd: Fix UB type punning Upstream commit c3a91c3bc62bdd913c55dd83f4e1159ed25310c5 KDE-bug: https://bugs.kde.org/show_bug.cgi?id=471829 Bug: https://bugs.gentoo.org/910062 Signed-off-by: Andreas Sturmlechner gentoo.org> ...geformats-5.108.0-psd-fix-UB-type-punning.patch | 89 ++++++++++++++++++++++ .../kimageformats/kimageformats-5.108.0-r1.ebuild | 45 +++++++++++ 2 files changed, 134 insertions(+) diff --git a/kde-frameworks/kimageformats/files/kimageformats-5.108.0-psd-fix-UB-type-punning.patch b/kde-frameworks/kimageformats/files/kimageformats-5.108.0-psd-fix-UB-type-punning.patch new file mode 100644 index 000000000000..68d853a5f447 --- /dev/null +++ b/kde-frameworks/kimageformats/files/kimageformats-5.108.0-psd-fix-UB-type-punning.patch @@ -0,0 +1,89 @@ +From c3a91c3bc62bdd913c55dd83f4e1159ed25310c5 Mon Sep 17 00:00:00 2001 +From: Mirco Miranda +Date: Sun, 16 Jul 2023 08:03:58 +0000 +Subject: [PATCH] psd: Fix UB type punning + +BUGS: 471829 +--- + src/imageformats/psd.cpp | 33 ++++++++++++++++++++++++++------- + 1 file changed, 26 insertions(+), 7 deletions(-) + +diff --git a/src/imageformats/psd.cpp b/src/imageformats/psd.cpp +index 7280aea..b0c76e2 100644 +--- a/src/imageformats/psd.cpp ++++ b/src/imageformats/psd.cpp +@@ -42,6 +42,7 @@ + #include + + #include ++#include + + typedef quint32 uint; + typedef quint16 ushort; +@@ -808,6 +809,26 @@ inline quint32 xchg(quint32 v) { + #endif + } + ++inline float xchg(float v) ++{ ++#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN ++# ifdef Q_CC_MSVC ++ float *pf = &v; ++ quint32 f = xchg(*reinterpret_cast(pf)); ++ quint32 *pi = &f; ++ return *reinterpret_cast(pi); ++# else ++ quint32 t; ++ std::memcpy(&t, &v, sizeof(quint32)); ++ t = xchg(t); ++ std::memcpy(&v, &t, sizeof(quint32)); ++ return v; ++# endif ++#else ++ return v; // never tested ++#endif ++} ++ + template + inline void planarToChunchy(uchar *target, const char *source, qint32 width, qint32 c, qint32 cn) + { +@@ -818,15 +839,13 @@ inline void planarToChunchy(uchar *target, const char *source, qint32 width, qin + } + } + +-template +-inline void planarToChunchyFloat(uchar *target, const char *source, qint32 width, qint32 c, qint32 cn) ++template ++inline void planarToChunchyFloatToUInt16(uchar *target, const char *source, qint32 width, qint32 c, qint32 cn) + { + auto s = reinterpret_cast(source); + auto t = reinterpret_cast(target); + for (qint32 x = 0; x < width; ++x) { +- auto tmp = xchg(s[x]); +- auto ftmp = (*reinterpret_cast(&tmp) - double(min)) / (double(max) - double(min)); +- t[x * cn + c] = quint16(std::min(ftmp * std::numeric_limits::max() + 0.5, double(std::numeric_limits::max()))); ++ t[x * cn + c] = quint16(std::min(xchg(s[x]) * std::numeric_limits::max() + 0.5, double(std::numeric_limits::max()))); + } + } + +@@ -1140,7 +1159,7 @@ static bool LoadPSD(QDataStream &stream, const PSDHeader &header, QImage &img) + } else if (header.depth == 16) { + planarToChunchy(scanLine, rawStride.data(), header.width, c, header.channel_count); + } else if (header.depth == 32) { +- planarToChunchyFloat(scanLine, rawStride.data(), header.width, c, header.channel_count); ++ planarToChunchyFloatToUInt16(scanLine, rawStride.data(), header.width, c, header.channel_count); + } + } + +@@ -1204,7 +1223,7 @@ static bool LoadPSD(QDataStream &stream, const PSDHeader &header, QImage &img) + } else if (header.depth == 16) { // 16-bits integer images: Grayscale, RGB/RGBA + planarToChunchy(scanLine, rawStride.data(), header.width, c, imgChannels); + } else if (header.depth == 32) { // 32-bits float images: Grayscale, RGB/RGBA (coverted to equivalent integer 16-bits) +- planarToChunchyFloat(scanLine, rawStride.data(), header.width, c, imgChannels); ++ planarToChunchyFloatToUInt16(scanLine, rawStride.data(), header.width, c, imgChannels); + } + } + } +-- +GitLab + diff --git a/kde-frameworks/kimageformats/kimageformats-5.108.0-r1.ebuild b/kde-frameworks/kimageformats/kimageformats-5.108.0-r1.ebuild new file mode 100644 index 000000000000..06b7edcba3c2 --- /dev/null +++ b/kde-frameworks/kimageformats/kimageformats-5.108.0-r1.ebuild @@ -0,0 +1,45 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +ECM_QTHELP="false" +PVCUT=$(ver_cut 1-2) +QTMIN=5.15.9 +inherit ecm frameworks.kde.org + +DESCRIPTION="Framework providing additional format plugins for Qt's image I/O system" + +LICENSE="LGPL-2+" +KEYWORDS="~amd64 ~arm ~arm64 ~loong ~ppc64 ~riscv ~x86" +IUSE="avif eps heif jpegxl openexr raw" + +RDEPEND=" + >=dev-qt/qtgui-${QTMIN}:5 + =kde-frameworks/karchive-${PVCUT}*:5 + avif? ( >=media-libs/libavif-0.8.2:= ) + eps? ( >=dev-qt/qtprintsupport-${QTMIN}:5 ) + heif? ( >=media-libs/libheif-1.10.0:= ) + jpegxl? ( media-libs/libjxl ) + openexr? ( >=media-libs/openexr-3:= ) + raw? ( media-libs/libraw:= ) +" +DEPEND="${RDEPEND} + test? ( heif? ( media-libs/libheif[x265] ) ) +" + +DOCS=( src/imageformats/AUTHORS ) + +PATCHES=( "${FILESDIR}/${P}-psd-fix-UB-type-punning.patch" ) # 5.109 + +src_configure() { + local mycmakeargs=( + -DKIMAGEFORMATS_JXL=$(usex jpegxl) + $(cmake_use_find_package avif libavif) + $(cmake_use_find_package eps Qt5PrintSupport) + -DKIMAGEFORMATS_HEIF=$(usex heif) + $(cmake_use_find_package openexr OpenEXR) + $(cmake_use_find_package raw LibRaw) + ) + ecm_src_configure +}