From 2758af36eeba2ba0db0ef333f5c990351cefd897 Mon Sep 17 00:00:00 2001 From: Andrew Bettison Date: Tue, 10 Jul 2012 14:26:19 +0930 Subject: [PATCH] Silence strict-aliasing warnings --- sha2.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sha2.c b/sha2.c index fcf92f03..1761470d 100644 --- a/sha2.c +++ b/sha2.c @@ -606,7 +606,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; + sha2_word64* p = (sha2_word64*) &context->buffer[SHA256_SHORT_BLOCK_LENGTH]; + p[0] = context->bitcount; /* Final transform: */ SHA256_Transform(context, (sha2_word32*)context->buffer); @@ -923,8 +924,9 @@ 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]; + sha2_word64* p = (sha2_word64*) &context->buffer[SHA512_SHORT_BLOCK_LENGTH]; + p[0] = context->bitcount[1]; + p[1] = context->bitcount[0]; /* Final transform: */ SHA512_Transform(context, (sha2_word64*)context->buffer);