]> granicus.if.org Git - apache/commitdiff
use apr_pstrndup() instead of apr_pstrdup() to avoid a strlen call in
authorDoug MacEachern <dougm@apache.org>
Wed, 28 Nov 2001 05:00:34 +0000 (05:00 +0000)
committerDoug MacEachern <dougm@apache.org>
Wed, 28 Nov 2001 05:00:34 +0000 (05:00 +0000)
ap_md5_binary, since we know the length of the string is always
MD5_DIGESTSIZE * 2
PR:
Obtained from:
Submitted by:
Reviewed by:

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92212 13f79535-47bb-0310-9956-ffa450edef68

server/util_md5.c

index 9f19d62add1303cd50f1068ce74dece98e43d88b..d9b1f1380c7cc5c8e6f6f953c734ec8f16470c66 100644 (file)
@@ -97,7 +97,7 @@ AP_DECLARE(char *) ap_md5_binary(apr_pool_t *p, const unsigned char *buf, int le
     const char *hex = "0123456789abcdef";
     apr_md5_ctx_t my_md5;
     unsigned char hash[MD5_DIGESTSIZE];
-    char *r, result[33];
+    char *r, result[33]; /* (MD5_DIGESTSIZE * 2) + 1 */
     int i;
 
     /*
@@ -117,7 +117,7 @@ AP_DECLARE(char *) ap_md5_binary(apr_pool_t *p, const unsigned char *buf, int le
     }
     *r = '\0';
 
-    return apr_pstrdup(p, result);
+    return apr_pstrndup(p, result, MD5_DIGESTSIZE*2);
 }
 
 AP_DECLARE(char *) ap_md5(apr_pool_t *p, const unsigned char *string)