summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pipping <sping@gentoo.org>2024-05-05 22:13:23 +0200
committerSebastian Pipping <sping@gentoo.org>2024-05-05 22:13:23 +0200
commit670caca7e19121f32709d524fc6c42a921866479 (patch)
tree9c63d864d01215c41c517e14a8889d4fd7f7da52 /sys-apps
parentdev-build/meson: Stabilize 1.4.0-r1 hppa, #930997 (diff)
downloadgentoo-670caca7e19121f32709d524fc6c42a921866479.tar.gz
gentoo-670caca7e19121f32709d524fc6c42a921866479.tar.bz2
gentoo-670caca7e19121f32709d524fc6c42a921866479.zip
sys-apps/dcfldd: Fix miscompilation through Sam's upstream patch
Closes: https://bugs.gentoo.org/930996 Signed-off-by: Sebastian Pipping <sping@gentoo.org>
Diffstat (limited to 'sys-apps')
-rw-r--r--sys-apps/dcfldd/dcfldd-1.9.1-r2.ebuild37
-rw-r--r--sys-apps/dcfldd/files/dcfldd-1.9.1-miscompile.patch44
2 files changed, 81 insertions, 0 deletions
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);