www-apache-bugdb mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Life is hard, and then you die." <ron...@innovation.ch>
Subject Re: other/3409: [PATCH] ap_md5_binary uses sprintf, which is unnecessarily slow
Date Fri, 20 Nov 1998 09:20:00 GMT
The following reply was made to PR other/3409; it has been noted by GNATS.

From: "Life is hard, and then you die." <ronald@innovation.ch>
To: apbugs@hyperreal.org, apache-bugdb@apache.org
Cc:  Subject: Re: other/3409: [PATCH] ap_md5_binary uses sprintf, which is unnecessarily slow
Date: Fri, 20 Nov 1998 10:11:17 +0100 (MET)

 Erm, let me modify that patch slightly - using an array for "hex" is
 stupid... Sorry.
 
 --- main/util_md5.c.orig        Sun Sep  6 12:12:18 1998
 +++ main/util_md5.c     Tue Nov 17 23:23:46 1998
 @@ -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);
 

Mime
View raw message