projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
.
[gnulib.git]
/
lib
/
md5.c
diff --git
a/lib/md5.c
b/lib/md5.c
index
61ae19d
..
8114795
100644
(file)
--- a/
lib/md5.c
+++ b/
lib/md5.c
@@
-24,6
+24,15
@@
#include <sys/types.h>
#include <sys/types.h>
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <string.h>
+#else
+# ifndef HAVE_MEMCPY
+# define memcpy(d, s, n) bcopy ((s), (d), (n))
+# endif
+#endif
+
#include "md5.h"
#ifdef WORDS_BIGENDIAN
#include "md5.h"
#ifdef WORDS_BIGENDIAN
@@
-69,7
+78,7
@@
md5_read_ctx (ctx, resbuf)
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
/* Compute MD5 message digest for bytes read from STREAM. The
resulting message digest number will be written into the 16 bytes
beginning at RESBLOCK. */
-void *
+int
md5_stream (stream, resblock)
FILE *stream;
void *resblock;
md5_stream (stream, resblock)
FILE *stream;
void *resblock;
@@
-104,6
+113,8
@@
md5_stream (stream, resblock)
sum += n;
}
while (sum < BLOCKSIZE && n != 0);
sum += n;
}
while (sum < BLOCKSIZE && n != 0);
+ if (n == 0 && ferror (stream))
+ return 1;
/* 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
/* 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
@@
-135,13
+146,15
@@
md5_stream (stream, resblock)
/* Put the 64-bit file length in *bits* at the end of the buffer. */
*(md5_uint32 *) &buffer[sum + pad] = SWAP (len[0] << 3);
/* Put the 64-bit file length in *bits* at the end of the buffer. */
*(md5_uint32 *) &buffer[sum + pad] = SWAP (len[0] << 3);
- *(md5_uint32 *) &buffer[sum + pad + 4] = SWAP ((len[1] << 3) | (len[0] >> 29));
+ *(md5_uint32 *) &buffer[sum + pad + 4] = SWAP ((len[1] << 3)
+ | (len[0] >> 29));
/* Process last bytes. */
md5_process_block (buffer, sum + pad + 8, &ctx);
/* Construct result in desired memory. */
/* Process last bytes. */
md5_process_block (buffer, sum + pad + 8, &ctx);
/* Construct result in desired memory. */
- return md5_read_ctx (&ctx, resblock);
+ md5_read_ctx (&ctx, resblock);
+ return 0;
}
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
}
/* Compute MD5 message digest for LEN bytes beginning at BUFFER. The
@@
-178,8
+191,8
@@
md5_buffer (buffer, len, resblock)
pad = rest >= 56 ? 64 + 56 - rest : 56 - rest;
/* Put length of buffer in *bits* in last eight bytes. */
pad = rest >= 56 ? 64 + 56 - rest : 56 - rest;
/* Put length of buffer in *bits* in last eight bytes. */
- *(md5_uint32 *) &restbuf[rest + pad] = SWAP (len << 3);
- *(md5_uint32 *) &restbuf[rest + pad + 4] = SWAP (len >> 29);
+ *(md5_uint32 *) &restbuf[rest + pad] =
(md5_uint32)
SWAP (len << 3);
+ *(md5_uint32 *) &restbuf[rest + pad + 4] =
(md5_uint32)
SWAP (len >> 29);
/* Process last bytes. */
md5_process_block (restbuf, rest + pad + 8, &ctx);
/* Process last bytes. */
md5_process_block (restbuf, rest + pad + 8, &ctx);