projects
/
oweals
/
busybox.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix a silly off-by-one error noticed by Santiago Garcia Mantinan <manty@debian.org>
[oweals/busybox.git]
/
md5sum.c
diff --git
a/md5sum.c
b/md5sum.c
index 97a940059ed98088bba393274ea44431542f17e0..a9bbdef369f1c0b3b344f112a3bdde72d41bc466 100644
(file)
--- a/
md5sum.c
+++ b/
md5sum.c
@@
-20,11
+20,11
@@
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
/* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
/* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
-#include "busybox.h"
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <getopt.h>
#include <stdio.h>
#include <errno.h>
#include <ctype.h>
#include <getopt.h>
+#include "busybox.h"
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
#undef TRUE
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
#undef TRUE
@@
-181,7
+181,14
@@
extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
//--------end of md5.h
//----------------------------------------------------------------------------
//--------end of md5.h
//----------------------------------------------------------------------------
-#define SWAP(n) (n)
+/* Handle endian-ness */
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+ #define SWAP(n) (n)
+#else
+ #define SWAP(n) ((n << 24) | ((n&65280)<<8) | ((n&16711680)>>8) | (n>>24))
+#endif
+
+
/* This array contains the bytes used to pad the buffer to the next
64-byte boundary. (RFC 1321, 3.1: Step 1) */
/* This array contains the bytes used to pad the buffer to the next
64-byte boundary. (RFC 1321, 3.1: Step 1) */
@@
-819,8
+826,6
@@
int md5sum_main(int argc,
if (string == NULL)
string = (char **) xmalloc ((argc - 1) * sizeof (char *));
if (string == NULL)
string = (char **) xmalloc ((argc - 1) * sizeof (char *));
- if (optarg == NULL)
- optarg = "";
string[n_strings++] = optarg;
break;
}
string[n_strings++] = optarg;
break;
}
@@
-850,7
+855,7
@@
int md5sum_main(int argc,
break;
default:
break;
default:
-
usage(md5sum_usage
);
+
show_usage(
);
}
}
}
}
@@
-901,7
+906,12
@@
int md5sum_main(int argc,
fail = md5_file (file, binary, md5buffer);
err |= fail;
fail = md5_file (file, binary, md5buffer);
err |= fail;
- if (!fail) {
+ if (!fail && STREQ(file, "-")) {
+ size_t i;
+ for (i = 0; i < 16; ++i)
+ printf ("%02x", md5buffer[i]);
+ putchar ('\n');
+ } else if (!fail) {
size_t i;
/* Output a leading backslash if the file name contains
a newline or backslash. */
size_t i;
/* Output a leading backslash if the file name contains
a newline or backslash. */