aboutsummaryrefslogtreecommitdiffstats
path: root/lib/md5.c
diff options
context:
space:
mode:
authorPaul Eggert2012-05-26 16:14:36 -0700
committerPaul Eggert2012-05-26 16:14:36 -0700
commitcaf8a9b2b301aba06735d403317b75b41df59bfe (patch)
treebfafb3cc0cf8a2f2394b4ed721e7c3d4891b78ab /lib/md5.c
parentfe453991eafc32a890297a2003ac532b9f579f92 (diff)
downloademacs-caf8a9b2b301aba06735d403317b75b41df59bfe.tar.gz
emacs-caf8a9b2b301aba06735d403317b75b41df59bfe.zip
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 @@
1/* Functions to compute MD5 message digest of files or memory blocks. 1/* Functions to compute MD5 message digest of files or memory blocks.
2 according to the definition of MD5 in RFC 1321 from April 1992. 2 according to the definition of MD5 in RFC 1321 from April 1992.
3 Copyright (C) 1995-1997, 1999-2001, 2005-2006, 2008-2011 Free Software 3 Copyright (C) 1995-1997, 1999-2001, 2005-2006, 2008-2012 Free Software
4 Foundation, Inc. 4 Foundation, Inc.
5 This file is part of the GNU C Library. 5 This file is part of the GNU C Library.
6 6
@@ -15,8 +15,7 @@
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation, 18 along with this program; if not, see <http://www.gnu.org/licenses/>. */
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20 19
21/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */ 20/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
22 21
@@ -24,7 +23,8 @@
24 23
25#include "md5.h" 24#include "md5.h"
26 25
27#include <stddef.h> 26#include <stdalign.h>
27#include <stdint.h>
28#include <stdlib.h> 28#include <stdlib.h>
29#include <string.h> 29#include <string.h>
30#include <sys/types.h> 30#include <sys/types.h>
@@ -254,8 +254,7 @@ md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx)
254 if (len >= 64) 254 if (len >= 64)
255 { 255 {
256#if !_STRING_ARCH_unaligned 256#if !_STRING_ARCH_unaligned
257# define alignof(type) offsetof (struct { char c; type x; }, x) 257# define UNALIGNED_P(p) ((uintptr_t) (p) % alignof (uint32_t) != 0)
258# define UNALIGNED_P(p) (((size_t) p) % alignof (uint32_t) != 0)
259 if (UNALIGNED_P (buffer)) 258 if (UNALIGNED_P (buffer))
260 while (len > 64) 259 while (len > 64)
261 { 260 {
@@ -313,13 +312,13 @@ md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx)
313 uint32_t B = ctx->B; 312 uint32_t B = ctx->B;
314 uint32_t C = ctx->C; 313 uint32_t C = ctx->C;
315 uint32_t D = ctx->D; 314 uint32_t D = ctx->D;
315 uint32_t lolen = len;
316 316
317 /* First increment the byte count. RFC 1321 specifies the possible 317 /* First increment the byte count. RFC 1321 specifies the possible
318 length of the file up to 2^64 bits. Here we only compute the 318 length of the file up to 2^64 bits. Here we only compute the
319 number of bytes. Do a double word increment. */ 319 number of bytes. Do a double word increment. */
320 ctx->total[0] += len; 320 ctx->total[0] += lolen;
321 if (ctx->total[0] < len) 321 ctx->total[1] += (len >> 31 >> 1) + (ctx->total[0] < lolen);
322 ++ctx->total[1];
323 322
324 /* Process all bytes in the buffer with 64 bytes in each round of 323 /* Process all bytes in the buffer with 64 bytes in each round of
325 the loop. */ 324 the loop. */