summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormcf <mcf@pkgsrc.org>2022-02-15 05:25:38 +0000
committermcf <mcf@pkgsrc.org>2022-02-15 05:25:38 +0000
commit690c7f3217857e226d8d83739d35ef855c4bfd1e (patch)
tree0b0751cdf69efa87b913f2ba7349db8236db902d
parenta2ffa46f1f6b18b3ce009fb492f0c4ade70a2cad (diff)
downloadpkgsrc-690c7f3217857e226d8d83739d35ef855c4bfd1e.tar.gz
digest: fix aliasing bug with gcc 11
gcc 11 with -O2 optimizes away the store of the bit length into the last 8 bytes of the context buffer due to an aliasing violation (stored through uint64_t, retrieved through uint32_t). To fix this, import the NetBSD patch from christos[0] which makes it use memcpy instead. [0] http://cvsweb.netbsd.org/bsdweb.cgi/src/common/lib/libc/hash/sha2/sha2.c.diff?r1=1.12&r2=1.13
-rwxr-xr-xpkgtools/digest/files/configure4
-rw-r--r--pkgtools/digest/files/sha2.c3
2 files changed, 4 insertions, 3 deletions
diff --git a/pkgtools/digest/files/configure b/pkgtools/digest/files/configure
index f833c50c706..3b4bf12cb10 100755
--- a/pkgtools/digest/files/configure
+++ b/pkgtools/digest/files/configure
@@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='nbsd-digest'
PACKAGE_TARNAME='nbsd-digest'
-PACKAGE_VERSION='20211023'
-PACKAGE_STRING='nbsd-digest 20190127'
+PACKAGE_VERSION='20220214'
+PACKAGE_STRING='nbsd-digest 20220214'
PACKAGE_BUGREPORT='agc@netbsd.org'
PACKAGE_URL=''
diff --git a/pkgtools/digest/files/sha2.c b/pkgtools/digest/files/sha2.c
index 972a24fbbd3..f2cc9848719 100644
--- a/pkgtools/digest/files/sha2.c
+++ b/pkgtools/digest/files/sha2.c
@@ -548,7 +548,8 @@ void SHA256_Final(sha2_byte digest[], SHA256_CTX* context) {
*context->buffer = 0x80;
}
/* Set the bit count: */
- *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
+ MEMCPY_BCOPY(&context->buffer[SHA256_SHORT_BLOCK_LENGTH],
+ &context->bitcount, sizeof(context->bitcount));
/* Final transform: */
SHA256_Transform(context, (sha2_word32*)context->buffer);