]> mj.ucw.cz Git - libucw.git/commitdiff
MD5: Removed a potential pointer aliasing problem
authorMartin Mares <mj@ucw.cz>
Tue, 30 Oct 2012 20:26:46 +0000 (21:26 +0100)
committerMartin Mares <mj@ucw.cz>
Tue, 30 Oct 2012 20:26:46 +0000 (21:26 +0100)
Discovered from a warning by GCC 4.7.

ucw/md5.c

index ee8e206bc24c74563aeb801f5e5c9919d87d6177..b04278bc4b0b3c3f4ed382af9d38f0d94076bbee 100644 (file)
--- a/ucw/md5.c
+++ b/ucw/md5.c
@@ -139,9 +139,7 @@ byte *md5_final(md5_context *ctx)
   byteReverse(ctx->in, 14);
 
   /* Append length in bits and transform */
-  ((u32 *) ctx->in)[14] = ctx->bits[0];
-  ((u32 *) ctx->in)[15] = ctx->bits[1];
-
+  memcpy(ctx->in + 56, ctx->bits, 8);
   md5_transform(ctx->buf, (u32 *) ctx->in);
   byteReverse((byte *) ctx->buf, 4);
   return (byte *) ctx->buf;