about summary refs log tree commit diff
path: root/crypt/md5.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-07-19 16:53:43 -0400
committerUlrich Drepper <drepper@gmail.com>2011-07-19 16:53:43 -0400
commit7dc6bd90c569c49807462b0740b18e32fab4d8b7 (patch)
tree1b6b4a3df6408992625f329206dbe98619589a17 /crypt/md5.c
parente0e722848005e335132015a64a09cad7f7a12073 (diff)
downloadglibc-7dc6bd90c569c49807462b0740b18e32fab4d8b7.tar.gz
glibc-7dc6bd90c569c49807462b0740b18e32fab4d8b7.tar.xz
glibc-7dc6bd90c569c49807462b0740b18e32fab4d8b7.zip
Use union to avoid casts in code to store results of hashsum computations
Diffstat (limited to 'crypt/md5.c')
-rw-r--r--crypt/md5.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/crypt/md5.c b/crypt/md5.c
index 922e7cc7e9..9bdb8e6aa6 100644
--- a/crypt/md5.c
+++ b/crypt/md5.c
@@ -1,6 +1,6 @@
 /* Functions to compute MD5 message digest of files or memory blocks.
    according to the definition of MD5 in RFC 1321 from April 1992.
-   Copyright (C) 1995,1996,1997,1999,2000,2001,2005
+   Copyright (C) 1995,1996,1997,1999,2000,2001,2005,2011
 	Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -123,9 +123,9 @@ md5_finish_ctx (ctx, resbuf)
   memcpy (&ctx->buffer[bytes], fillbuf, pad);
 
   /* Put the 64-bit file length in *bits* at the end of the buffer.  */
-  *(md5_uint32 *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3);
-  *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) |
-							(ctx->total[0] >> 29));
+  ctx->buffer32[(bytes + pad) / 4] = SWAP (ctx->total[0] << 3);
+  ctx->buffer32[(bytes + pad + 4) / 4] = SWAP ((ctx->total[1] << 3) |
+					       (ctx->total[0] >> 29));
 
   /* Process last bytes.  */
   md5_process_block (ctx->buffer, bytes + pad + 8, ctx);
@@ -168,7 +168,7 @@ md5_stream (stream, resblock)
 	}
       while (sum < BLOCKSIZE && n != 0);
       if (n == 0 && ferror (stream))
-        return 1;
+	return 1;
 
       /* If end of file is reached, end the loop.  */
       if (n == 0)
@@ -340,12 +340,12 @@ md5_process_block (buffer, len, ctx)
 
 #define OP(a, b, c, d, s, T)						\
       do								\
-        {								\
+	{								\
 	  a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T;		\
 	  ++words;							\
 	  CYCLIC (a, s);						\
 	  a += b;							\
-        }								\
+	}								\
       while (0)
 
       /* It is unfortunate that C does not provide an operator for