You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/x11-misc/alock/files/fix-aliasing.patch

24 lines
1.1 KiB

--- a/src/auth_sha2.c
+++ b/src/auth_sha2.c
@@ -511,7 +517,8 @@
*context->buffer = 0x80;
}
/* Set the bit count: */
- *(u_int64_t *)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount;
+ /* Use memcpy so we're not casting or aliasing */
+ memcpy(&context->buffer[SHA256_SHORT_BLOCK_LENGTH], &context->bitcount, sizeof (context->bitcount));
/* Final transform: */
sha256_transform(context, context->buffer);
@@ -789,8 +796,8 @@
*context->buffer = 0x80;
}
/* Store the length of input data (in bits): */
- *(u_int64_t *)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1];
- *(u_int64_t *)&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, sizeof (context->bitcount));
/* Final transform: */
sha512_transform(context, context->buffer);