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 7E81915817D for ; Sun, 16 Jun 2024 10:28:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CA8E8E2A34; Sun, 16 Jun 2024 10:28:42 +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 B25F8E2A34 for ; Sun, 16 Jun 2024 10:28:42 +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)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 011A8335DC3 for ; Sun, 16 Jun 2024 10:28:42 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 8B0DA1ADC for ; Sun, 16 Jun 2024 10:28:40 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1718533709.04d8c0b2f1069d63a1711862310d0052d1fd1502.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: media-libs/woff2/files/, media-libs/woff2/ X-VCS-Repository: repo/gentoo X-VCS-Files: media-libs/woff2/files/woff2-1.0.2-aliasing.patch media-libs/woff2/woff2-1.0.2-r6.ebuild X-VCS-Directories: media-libs/woff2/ media-libs/woff2/files/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 04d8c0b2f1069d63a1711862310d0052d1fd1502 X-VCS-Branch: master Date: Sun, 16 Jun 2024 10:28:40 +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: 7467548e-acc2-4bb3-8001-af1d979913ab X-Archives-Hash: a6d2c36066671b78d10826236a65a186 commit: 04d8c0b2f1069d63a1711862310d0052d1fd1502 Author: Sam James gentoo org> AuthorDate: Sun Jun 16 10:18:36 2024 +0000 Commit: Sam James gentoo org> CommitDate: Sun Jun 16 10:28:29 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=04d8c0b2 media-libs/woff2: fix strict aliasing violation Signed-off-by: Sam James gentoo.org> media-libs/woff2/files/woff2-1.0.2-aliasing.patch | 79 +++++++++++++++++++++++ media-libs/woff2/woff2-1.0.2-r6.ebuild | 41 ++++++++++++ 2 files changed, 120 insertions(+) diff --git a/media-libs/woff2/files/woff2-1.0.2-aliasing.patch b/media-libs/woff2/files/woff2-1.0.2-aliasing.patch new file mode 100644 index 000000000000..5bc75b744559 --- /dev/null +++ b/media-libs/woff2/files/woff2-1.0.2-aliasing.patch @@ -0,0 +1,79 @@ +https://github.com/google/woff2/commit/23a34adec39d7cef30c1eebbf775a1ea5cc43c53 + +From 23a34adec39d7cef30c1eebbf775a1ea5cc43c53 Mon Sep 17 00:00:00 2001 +From: David Benjamin +Date: Thu, 26 Oct 2023 10:16:05 -0400 +Subject: [PATCH] Fix undefined type-punning when loading/storing words + +Despite common practice, type-punning integer types out of buffers is +undefined in C and C++. It's both a strict aliasing violation on access, +and if the pointer isn't aligned, an alignment violation on cast. Being +undefined, the compiler is allowed to arbitrarily miscompile the code +when we rely on it. + +Instead, the two legal ways to pull a uint32_t out of a buffer are to +either use memcpy, or load byte by byte and use shifts. In both cases, +a good compiler should be smart enough to recognize what we're doing and +generate reasonable code. Since there was already fallback code for the +latter (for a middle-endian architecture?), I went ahead and switched to +that. + +This change is needed to fix UBSan violations in Chromium. +--- a/src/store_bytes.h ++++ b/src/store_bytes.h +@@ -27,15 +27,8 @@ inline size_t StoreU32(uint8_t* dst, size_t offset, uint32_t x) { + } + + inline size_t Store16(uint8_t* dst, size_t offset, int x) { +-#if defined(WOFF_LITTLE_ENDIAN) +- *reinterpret_cast(dst + offset) = +- ((x & 0xFF) << 8) | ((x & 0xFF00) >> 8); +-#elif defined(WOFF_BIG_ENDIAN) +- *reinterpret_cast(dst + offset) = static_cast(x); +-#else + dst[offset] = x >> 8; + dst[offset + 1] = x; +-#endif + return offset + 2; + } + +@@ -47,17 +40,8 @@ inline void StoreU32(uint32_t val, size_t* offset, uint8_t* dst) { + } + + inline void Store16(int val, size_t* offset, uint8_t* dst) { +-#if defined(WOFF_LITTLE_ENDIAN) +- *reinterpret_cast(dst + *offset) = +- ((val & 0xFF) << 8) | ((val & 0xFF00) >> 8); +- *offset += 2; +-#elif defined(WOFF_BIG_ENDIAN) +- *reinterpret_cast(dst + *offset) = static_cast(val); +- *offset += 2; +-#else + dst[(*offset)++] = val >> 8; + dst[(*offset)++] = val; +-#endif + } + + inline void StoreBytes(const uint8_t* data, size_t len, +--- a/src/woff2_common.cc ++++ b/src/woff2_common.cc +@@ -19,16 +19,8 @@ uint32_t ComputeULongSum(const uint8_t* buf, size_t size) { + uint32_t checksum = 0; + size_t aligned_size = size & ~3; + for (size_t i = 0; i < aligned_size; i += 4) { +-#if defined(WOFF_LITTLE_ENDIAN) +- uint32_t v = *reinterpret_cast(buf + i); +- checksum += (((v & 0xFF) << 24) | ((v & 0xFF00) << 8) | +- ((v & 0xFF0000) >> 8) | ((v & 0xFF000000) >> 24)); +-#elif defined(WOFF_BIG_ENDIAN) +- checksum += *reinterpret_cast(buf + i); +-#else +- checksum += (buf[i] << 24) | (buf[i + 1] << 16) | +- (buf[i + 2] << 8) | buf[i + 3]; +-#endif ++ checksum += ++ (buf[i] << 24) | (buf[i + 1] << 16) | (buf[i + 2] << 8) | buf[i + 3]; + } + + // treat size not aligned on 4 as if it were padded to 4 with 0's + diff --git a/media-libs/woff2/woff2-1.0.2-r6.ebuild b/media-libs/woff2/woff2-1.0.2-r6.ebuild new file mode 100644 index 000000000000..f104cb69f87d --- /dev/null +++ b/media-libs/woff2/woff2-1.0.2-r6.ebuild @@ -0,0 +1,41 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit cmake + +DESCRIPTION="Encode/decode WOFF2 font format" +HOMEPAGE="https://github.com/google/woff2" +SRC_URI="https://github.com/google/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris" +IUSE="" + +RDEPEND="app-arch/brotli:=" +DEPEND="${RDEPEND}" +BDEPEND="virtual/pkgconfig" + +PATCHES=( + "${FILESDIR}"/${P}-aliasing.patch +) + +src_configure() { + local mycmakeargs=( + -DCMAKE_SKIP_RPATH=ON # needed, causes QA warnings otherwise + -DCANONICAL_PREFIXES=ON #661942 + ) + cmake_src_configure +} + +src_install() { + cmake_src_install + + dobin "${BUILD_DIR}"/woff2_compress + dobin "${BUILD_DIR}"/woff2_decompress + dobin "${BUILD_DIR}"/woff2_info + + einstalldocs +}