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
This commit is contained in:
parent
0ab885eabc
commit
b631703ee1
2 changed files with 4 additions and 3 deletions
4
pkgtools/digest/files/configure
vendored
4
pkgtools/digest/files/configure
vendored
|
@ -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=''
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue