From: Doug MacEachern Date: Wed, 28 Nov 2001 05:00:34 +0000 (+0000) Subject: use apr_pstrndup() instead of apr_pstrdup() to avoid a strlen call in X-Git-Tag: 2.0.30~365 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b6c2d55889353d9bfcac15912f4a8af45e4107a;p=apache use apr_pstrndup() instead of apr_pstrdup() to avoid a strlen call in 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 --- diff --git a/server/util_md5.c b/server/util_md5.c index 9f19d62add..d9b1f1380c 100644 --- a/server/util_md5.c +++ b/server/util_md5.c @@ -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)