summaryrefslogtreecommitdiffstats
path: root/libmd5
diff options
context:
space:
mode:
Diffstat (limited to 'libmd5')
-rw-r--r--libmd5/md5.c20
-rw-r--r--libmd5/md5.h2
2 files changed, 8 insertions, 14 deletions
diff --git a/libmd5/md5.c b/libmd5/md5.c
index d0627ff..1fdcb3a 100644
--- a/libmd5/md5.c
+++ b/libmd5/md5.c
@@ -31,13 +31,13 @@ MD5Transform(UWORD32 buf[4], UWORD32 const in[16]);
int g_bigEndian = 0;
int g_endianessDetected = 0;
-static void
+static void
detectEndianess()
{
int nl = 0x12345678;
short ns = 0x1234;
- unsigned char *p = (unsigned char *)(&nl);
+ unsigned char *p = (unsigned char *)(&nl);
unsigned char *sp = (unsigned char *)(&ns);
if (g_endianessDetected) return;
@@ -132,7 +132,7 @@ MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
}
/*
- * Final wrapup - pad to 64-byte boundary with the bit pattern
+ * Final wrapup - pad to 64-byte boundary with the bit pattern
* 1 0* (64-bit count of bits processed, MSB-first)
*/
void
@@ -282,14 +282,13 @@ void MD5Buffer (const unsigned char *buf,unsigned int len,unsigned char sig[16])
#define HEX_STRING "0123456789abcdef" /* to convert to hex */
-void MD5SigToString(unsigned char signature[16],char *str,int len)
+void MD5SigToString(unsigned char signature[16],char str[33])
{
unsigned char *sig_p;
- char *str_p, *max_p;
+ char *str_p;
unsigned int high, low;
str_p = str;
- max_p = str + len;
for (sig_p = (unsigned char *)signature;
sig_p < (unsigned char *)signature + 16;
@@ -298,16 +297,11 @@ void MD5SigToString(unsigned char signature[16],char *str,int len)
high = *sig_p / 16;
low = *sig_p % 16;
/* account for 2 chars */
- if (str_p + 1 >= max_p) {
- break;
- }
*str_p++ = HEX_STRING[high];
*str_p++ = HEX_STRING[low];
}
- /* account for 2 chars */
- if (str_p < max_p) {
- *str_p++ = '\0';
- }
+ /* account for 1 terminator */
+ *str_p++ = '\0';
}
diff --git a/libmd5/md5.h b/libmd5/md5.h
index 03f8ff6..5d0c0b0 100644
--- a/libmd5/md5.h
+++ b/libmd5/md5.h
@@ -48,7 +48,7 @@ void MD5Init(struct MD5Context *context);
void MD5Update(struct MD5Context *context, md5byte const *buf, unsigned len);
void MD5Final(unsigned char digest[16], struct MD5Context *context);
void MD5Buffer (const unsigned char *buf,unsigned int len,unsigned char sig[16]);
-void MD5SigToString(unsigned char sig[16],char *str,int len);
+void MD5SigToString(unsigned char sig[16],char str[33]);
#ifdef __cplusplus
}