summaryrefslogtreecommitdiff
path: root/lib/md5.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-05-26 16:14:36 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2012-05-26 16:14:36 -0700
commitcaf8a9b2b301aba06735d403317b75b41df59bfe (patch)
treebfafb3cc0cf8a2f2394b4ed721e7c3d4891b78ab /lib/md5.c
parentfe453991eafc32a890297a2003ac532b9f579f92 (diff)
downloademacs-caf8a9b2b301aba06735d403317b75b41df59bfe.tar.gz
Merge from gnulib.
Fixes: debbugs:11527
Diffstat (limited to 'lib/md5.c')
-rw-r--r--lib/md5.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/md5.c b/lib/md5.c
index b7fad633364..30b7e50e3ae 100644
--- a/lib/md5.c
+++ b/lib/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-1997, 1999-2001, 2005-2006, 2008-2011 Free Software
+ Copyright (C) 1995-1997, 1999-2001, 2005-2006, 2008-2012 Free Software
Foundation, Inc.
This file is part of the GNU C Library.
@@ -15,8 +15,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program; if not, see <http://www.gnu.org/licenses/>. */
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
@@ -24,7 +23,8 @@
#include "md5.h"
-#include <stddef.h>
+#include <stdalign.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
@@ -254,8 +254,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
if (len >= 64)
{
#if !_STRING_ARCH_unaligned
-# define alignof(type) offsetof (struct { char c; type x; }, x)
-# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0)
+# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
if (UNALIGNED_P (buffer))
while (len > 64)
{
@@ -313,13 +312,13 @@ md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx)
uint32_t B = ctx->B;
uint32_t C = ctx->C;
uint32_t D = ctx->D;
+ uint32_t lolen = len;
/* First increment the byte count. RFC 1321 specifies the possible
length of the file up to 2^64 bits. Here we only compute the
number of bytes. Do a double word increment. */
- ctx->total[0] += len;
- if (ctx->total[0] < len)
- ++ctx->total[1];
+ ctx->total[0] += lolen;
+ ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen);
/* Process all bytes in the buffer with 64 bytes in each round of
the loop. */