1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

lib: Fix strict-aliasing warning in md5 code.

If the compiler detects strict aliasing problems it isn't able to
optimize the code.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Günther Deschner <gd@samba.org>
This commit is contained in:
Andreas Schneider 2014-01-09 14:50:18 +01:00 committed by Andreas Schneider
parent 044f8f7190
commit 615efa4ae8

View File

@ -137,9 +137,12 @@ _PUBLIC_ void MD5Final(uint8_t digest[16], MD5_CTX *ctx)
}
byteReverse(ctx->in, 14);
/* Append length in bits and transform */
((uint32_t *) ctx->in)[14] = ctx->bits[0];
((uint32_t *) ctx->in)[15] = ctx->bits[1];
/* Append length in bits and transform.
* Use memcpy to avoid strict-aliasing problems.
* This way it can be optimized.
*/
memcpy(&ctx->in[14 * sizeof(uint32_t)], &ctx->bits[0], sizeof(uint32_t));
memcpy(&ctx->in[15 * sizeof(uint32_t)], &ctx->bits[1], sizeof(uint32_t));
MD5Transform(ctx->buf, (uint32_t *) ctx->in);
byteReverse((uint8_t *) ctx->buf, 4);