sha256.c: In function 'sr_SHA256_Final': sha256.c:613:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] *(sha2_word64*)&context->buffer[SHA256_SHORT_BLOCK_LENGTH] = context->bitcount; ^ sha256.c: In function 'SHA512_Last': sha256.c:930:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH] = context->bitcount[1]; ^ sha256.c:931:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] *(sha2_word64*)&context->buffer[SHA512_SHORT_BLOCK_LENGTH+8] = context->bitcount[0]; ^
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/626
-- Commit Summary --
* lib/srutils: fix gcc warning GH#612
-- File Changes --
M lib/srutils/sha256.c (6)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/626.patch https://github.com/kamailio/kamailio/pull/626.diff
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/626
This little test program shows same output before and after patch.
` #include <stdio.h> #include "sha256.h" #include "shautils.h" #define BUFSIZE 1024
int main(void) {
uint8_t buffer[BUFSIZE]; uint8_t src[2];
src[0]='a'; src[1]=0x0a;
compute_sha256((char *)buffer, (uint8_t *)&src, sizeof(src)); buffer[SHA256_DIGEST_STRING_LENGTH -1] = '\0'; printf("%s\n", buffer);
compute_sha512((char *)buffer, (uint8_t *)&src, sizeof(src)); buffer[SHA512_DIGEST_STRING_LENGTH -1] = '\0'; printf("%s\n", buffer);
return 0;
}
` Output is also same when compared to /sbin/sha256 and /sbin/sha512 (FreeBSD 10).
` % gcc -Wall shatest.c ../../md5.o sha256.o shautils.o
% ./a.out 87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7 162b0b32f02482d5aca0a7c93dd03ceac3acd7e410a5f18f3fb990fc958ae0df6f32233b91831eaf99ca581a8c4ddf9c8ba315ac482db6d4ea01cc7884a635be % echo a|sha256 ; echo a|sha512 87428fc522803d31065e7bce3cf03fe475096631e5e07bbd7a0fde60c4cf25c7 162b0b32f02482d5aca0a7c93dd03ceac3acd7e410a5f18f3fb990fc958ae0df6f32233b91831eaf99ca581a8c4ddf9c8ba315ac482db6d4ea01cc7884a635be % `
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/626#issuecomment-219704725
Thanks!
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/626#issuecomment-219926753
Merged #626.
--- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/pull/626#event-663925769