Module: kamailio
Branch: master
Commit: 5261d61f8202689204242c218fdd17ce3b2e461b
URL:
https://github.com/kamailio/kamailio/commit/5261d61f8202689204242c218fdd17c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2016-05-18T07:10:55+02:00
Merge pull request #626 from mslehto/strict-aliasing
lib/srutils: fix gcc warning GH#612
---
Modified: lib/srutils/sha256.c
---
Diff:
https://github.com/kamailio/kamailio/commit/5261d61f8202689204242c218fdd17c…
Patch:
https://github.com/kamailio/kamailio/commit/5261d61f8202689204242c218fdd17c…
---
diff --git a/lib/srutils/sha256.c b/lib/srutils/sha256.c
index 90efd15..2b40551 100644
--- a/lib/srutils/sha256.c
+++ b/lib/srutils/sha256.c
@@ -610,7 +610,7 @@ void sr_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(sha2_word64));
/* Final transform: */
SHA256_Transform(context, (sha2_word32*)context->buffer);
@@ -927,8 +927,8 @@ 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];
+ MEMCPY_BCOPY(&(context->buffer[SHA512_SHORT_BLOCK_LENGTH+0]),
&(context->bitcount[1]), sizeof(sha2_word64));
+ MEMCPY_BCOPY(&(context->buffer[SHA512_SHORT_BLOCK_LENGTH+8]),
&(context->bitcount[0]), sizeof(sha2_word64));
/* Final transform: */
SHA512_Transform(context, (sha2_word64*)context->buffer);