blob: a4462c25694372db45dab607e9e3d787f2ac1207 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
--- 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);
|