From 9ae65df5802f5f49751c851182ed2a90447c45f5 Mon Sep 17 00:00:00 2001 From: Jan Kaluza Date: Tue, 11 Dec 2012 11:07:28 +0100 Subject: [PATCH 1/2] Fix strict-aliasing gcc warning --- random/unix/sha2.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/random/unix/sha2.c b/random/unix/sha2.c index 212c1b7..887ac81 100644 --- a/random/unix/sha2.c +++ b/random/unix/sha2.c @@ -537,7 +537,14 @@ void apr__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; + { + union { + apr_uint64_t bitcount; + apr_byte_t bytes[8]; + } bitcount; + bitcount.bitcount = context->bitcount; + MEMCPY_BCOPY(&context->buffer[SHA256_SHORT_BLOCK_LENGTH], bitcount.bytes, 8); + } /* Final transform: */ apr__SHA256_Transform(context, (sha2_word32*)context->buffer); -- 1.8.0