public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: sys-apps/dcfldd/files/, sys-apps/dcfldd/
@ 2024-05-05 20:15 Sebastian Pipping
  0 siblings, 0 replies; only message in thread
From: Sebastian Pipping @ 2024-05-05 20:15 UTC (permalink / raw
  To: gentoo-commits

commit:     670caca7e19121f32709d524fc6c42a921866479
Author:     Sebastian Pipping <sping <AT> gentoo <DOT> org>
AuthorDate: Sun May  5 20:13:23 2024 +0000
Commit:     Sebastian Pipping <sping <AT> gentoo <DOT> org>
CommitDate: Sun May  5 20:13:23 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=670caca7

sys-apps/dcfldd: Fix miscompilation through Sam's upstream patch

Closes: https://bugs.gentoo.org/930996
Signed-off-by: Sebastian Pipping <sping <AT> gentoo.org>

 sys-apps/dcfldd/dcfldd-1.9.1-r2.ebuild             | 37 ++++++++++++++++++
 .../dcfldd/files/dcfldd-1.9.1-miscompile.patch     | 44 ++++++++++++++++++++++
 2 files changed, 81 insertions(+)

diff --git a/sys-apps/dcfldd/dcfldd-1.9.1-r2.ebuild b/sys-apps/dcfldd/dcfldd-1.9.1-r2.ebuild
new file mode 100644
index 000000000000..4add47a1a11a
--- /dev/null
+++ b/sys-apps/dcfldd/dcfldd-1.9.1-r2.ebuild
@@ -0,0 +1,37 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+inherit autotools bash-completion-r1
+
+DESCRIPTION="enhanced dd with features for forensics and security"
+HOMEPAGE="https://github.com/resurrecting-open-source-projects/dcfldd"
+SRC_URI="https://github.com/resurrecting-open-source-projects/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~ppc ~riscv ~x86"
+
+DEPEND="virtual/pkgconfig"
+
+PATCHES=(
+	"${FILESDIR}"/${P}-miscompile.patch
+)
+
+DOCS=(
+	AUTHORS
+	CONTRIBUTING.md
+	ChangeLog
+	NEWS
+	README.md
+)
+
+src_prepare() {
+	default
+	eautoreconf
+}
+
+src_install() {
+	default
+	newbashcomp doc/dcfldd-bash_completion dcfldd
+}

diff --git a/sys-apps/dcfldd/files/dcfldd-1.9.1-miscompile.patch b/sys-apps/dcfldd/files/dcfldd-1.9.1-miscompile.patch
new file mode 100644
index 000000000000..2969a8fe9102
--- /dev/null
+++ b/sys-apps/dcfldd/files/dcfldd-1.9.1-miscompile.patch
@@ -0,0 +1,44 @@
+From 393d5c41284292f72f2dd2a3c8e246e972ac718c Mon Sep 17 00:00:00 2001
+From: Sam James <sam@gentoo.org>
+Date: Thu, 11 Apr 2024 21:39:36 +0100
+Subject: [PATCH] sha2: fix aliasing violation
+
+`&context->buffer` is `uint8_t*`, but we try to access it as `sha2_word64*`, which
+is an aliasing violation (undefined behaviour).
+
+Use memcpy instead to avoid being miscompiled by e.g. >= GCC 12. This is
+just as fast with any modern compiler.
+
+Bug: https://gcc.gnu.org/PR114698
+Bug: https://github.com/NetBSD/pkgsrc/issues/122
+Bug: https://github.com/archiecobbs/libnbcompat/issues/4
+Bug: https://bugs.launchpad.net/ubuntu-power-systems/+bug/2033405
+Signed-off-by: Sam James <sam@gentoo.org>
+---
+ src/sha2.c | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/sha2.c b/src/sha2.c
+index bea1708..3925b97 100644
+--- a/src/sha2.c
++++ b/src/sha2.c
+@@ -604,7 +604,7 @@ void SHA256_Final(SHA256_CTX* context, sha2_byte digest[]) {
+ 			*context->buffer = 0x80;
+ 		}
+ 		/* Set the bit count: */
+-		*(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
++		memcpy(&context->buffer[SHA256_SHORT_BLOCK_LENGTH], &context->bitcount, sizeof(context->bitcount));
+ 
+ 		/* Final transform: */
+ 		SHA256_Transform(context, (sha2_word32*)context->buffer);
+@@ -921,8 +921,8 @@ void SHA512_Last(SHA512_CTX* context) {
+ 		*context->buffer = 0x80;
+ 	}
+ 	/* Store the length of input data (in bits): */
+-	*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1];
+-	*(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0];
++	memcpy(&context->buffer[SHA512_SHORT_BLOCK_LENGTH], &context->bitcount[1], sizeof(context->bitcount[1]));
++	memcpy(&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8], &context->bitcount[0], sizeof(context->bitcount[0]));
+ 
+ 	/* Final transform: */
+ 	SHA512_Transform(context, (sha2_word64*)context->buffer);


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-05 20:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-05 20:15 [gentoo-commits] repo/gentoo:master commit in: sys-apps/dcfldd/files/, sys-apps/dcfldd/ Sebastian Pipping

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox