coar 98/11/23 15:24:54
Modified: src/main util_md5.c
Log:
Change ap_md5_binary()'s hexification of the hash to use a
simple lookup rather than sprintf().
PR: 3409
Submitted by: Ronald Tschalar <[EMAIL PROTECTED]>
Reviewed by: Ken Coar
Revision Changes Path
1.16 +5 -2 apache-1.3/src/main/util_md5.c
Index: util_md5.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/main/util_md5.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- util_md5.c 1998/09/06 17:12:18 1.15
+++ util_md5.c 1998/11/23 23:24:54 1.16
@@ -89,6 +89,7 @@
API_EXPORT(char *) ap_md5_binary(pool *p, const unsigned char *buf, int
length)
{
+ const char *hex = "0123456789abcdef";
AP_MD5_CTX my_md5;
unsigned char hash[16];
char *r, result[33];
@@ -102,8 +103,10 @@
ap_MD5Update(&my_md5, buf, length);
ap_MD5Final(hash, &my_md5);
- for (i = 0, r = result; i < 16; i++, r += 2)
- sprintf(r, "%02x", hash[i]);
+ for (i = 0, r = result; i < 16; i++) {
+ *r++ = hex[hash[i] >> 4];
+ *r++ = hex[hash[i] & 0xF];
+ }
*r = '\0';
return ap_pstrdup(p, result);