From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1474981-garchives=archives.gentoo.org@lists.gentoo.org>
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 2A162158010
	for <garchives@archives.gentoo.org>; Sat,  7 Jan 2023 23:04:04 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 10B38E07C7;
	Sat,  7 Jan 2023 23:04:03 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.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) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id E617BE07C7
	for <gentoo-commits@lists.gentoo.org>; Sat,  7 Jan 2023 23:04:02 +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 C3291341047
	for <gentoo-commits@lists.gentoo.org>; Sat,  7 Jan 2023 23:04:01 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id EA61F7FB
	for <gentoo-commits@lists.gentoo.org>; Sat,  7 Jan 2023 23:03:59 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
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" <sam@gentoo.org>
Message-ID: <1673132437.8a1a91aa281cd0c6f2d3c2054ed9c866a04d594d.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: app-arch/pigz/, app-arch/pigz/files/
X-VCS-Repository: repo/gentoo
X-VCS-Files: app-arch/pigz/files/pigz-2.7-memcpy-ub.patch app-arch/pigz/pigz-2.7-r1.ebuild
X-VCS-Directories: app-arch/pigz/files/ app-arch/pigz/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 8a1a91aa281cd0c6f2d3c2054ed9c866a04d594d
X-VCS-Branch: master
Date: Sat,  7 Jan 2023 23:03:59 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: aa7e11d2-eba5-4b39-8304-be8241b9283b
X-Archives-Hash: f9a0f2ae18f7ec586142ea25745738a4

commit:     8a1a91aa281cd0c6f2d3c2054ed9c866a04d594d
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  7 23:00:31 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jan  7 23:00:37 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8a1a91aa

app-arch/pigz: backport memcpy UB fix

Signed-off-by: Sam James <sam <AT> gentoo.org>

 app-arch/pigz/files/pigz-2.7-memcpy-ub.patch | 26 +++++++++++++++++++
 app-arch/pigz/pigz-2.7-r1.ebuild             | 38 ++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)

diff --git a/app-arch/pigz/files/pigz-2.7-memcpy-ub.patch b/app-arch/pigz/files/pigz-2.7-memcpy-ub.patch
new file mode 100644
index 000000000000..db53660748b4
--- /dev/null
+++ b/app-arch/pigz/files/pigz-2.7-memcpy-ub.patch
@@ -0,0 +1,26 @@
+https://github.com/madler/pigz/commit/e1ed230a1599a3cb64c8f5c003cced60e10e3314
+https://github.com/madler/pigz/issues/107
+
+From e1ed230a1599a3cb64c8f5c003cced60e10e3314 Mon Sep 17 00:00:00 2001
+From: Mark Adler <madler@alumni.caltech.edu>
+Date: Sat, 31 Dec 2022 21:28:26 -0800
+Subject: [PATCH] Avoid calling memcpy() with a NULL pointer.
+
+This is not permitted by the C99 standard even when the length is
+zero. Go figure.
+--- a/pigz.c
++++ b/pigz.c
+@@ -3414,8 +3414,10 @@ local int outb(void *desc, unsigned char *buf, unsigned len) {
+ 
+         // copy the output and alert the worker bees
+         out_len = len;
+-        g.out_tot += len;
+-        memcpy(out_copy, buf, len);
++        if (len) {
++            g.out_tot += len;
++            memcpy(out_copy, buf, len);
++        }
+         twist(outb_write_more, TO, 1);
+         twist(outb_check_more, TO, 1);
+ 
+

diff --git a/app-arch/pigz/pigz-2.7-r1.ebuild b/app-arch/pigz/pigz-2.7-r1.ebuild
new file mode 100644
index 000000000000..f0a9d1f4540f
--- /dev/null
+++ b/app-arch/pigz/pigz-2.7-r1.ebuild
@@ -0,0 +1,38 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit toolchain-funcs flag-o-matic
+
+DESCRIPTION="A parallel implementation of gzip"
+HOMEPAGE="https://www.zlib.net/pigz/"
+SRC_URI="https://www.zlib.net/pigz/${P}.tar.gz"
+
+LICENSE="ZLIB"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~ppc-macos ~sparc64-solaris"
+IUSE="static test"
+RESTRICT="!test? ( test )"
+
+LIB_DEPEND="sys-libs/zlib[static-libs(+)]"
+RDEPEND="!static? ( ${LIB_DEPEND//\[static-libs(+)]} )"
+DEPEND="${RDEPEND}
+	static? ( ${LIB_DEPEND} )
+	test? ( app-arch/ncompress )"
+
+PATCHES=(
+	"${FILESDIR}"/${P}-memcpy-ub.patch
+)
+
+src_compile() {
+	use static && append-ldflags -static
+	emake CC="$(tc-getCC)" CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}"
+}
+
+src_install() {
+	dobin ${PN}
+	dosym ${PN} /usr/bin/un${PN}
+	dodoc README
+	doman ${PN}.1
+}