]> granicus.if.org Git - apache/commitdiff
Speed up ap_md5digest() a little.
authorJoe Orton <jorton@apache.org>
Thu, 17 Jul 2003 16:17:04 +0000 (16:17 +0000)
committerJoe Orton <jorton@apache.org>
Thu, 17 Jul 2003 16:17:04 +0000 (16:17 +0000)
* util_md5.c (ap_md5digest): Use a larger buffer; ensure size is a
multiple of 64 to prevent buffering in MD5 code.  Remove redundant
'length' variable.  Reset read size in case of short reads.

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

server/util_md5.c

index 5d8068b23bda0a51ff2fc54e2500992fa8c51c0c..6ec4571e1c6f2c1df3f95e69ed41eb4877c17bde 100644 (file)
@@ -198,16 +198,15 @@ AP_DECLARE(char *) ap_md5contextTo64(apr_pool_t *a, apr_md5_ctx_t *context)
 AP_DECLARE(char *) ap_md5digest(apr_pool_t *p, apr_file_t *infile)
 {
     apr_md5_ctx_t context;
-    unsigned char buf[1000];
-    long length = 0;
+    unsigned char buf[4096]; /* keep this a multiple of 64 */
     apr_size_t nbytes;
     apr_off_t offset = 0L;
 
     apr_md5_init(&context);
     nbytes = sizeof(buf);
     while (apr_file_read(infile, buf, &nbytes) == APR_SUCCESS) {
-       length += nbytes;
        apr_md5_update(&context, buf, nbytes);
+        nbytes = sizeof(buf);
     }
     apr_file_seek(infile, APR_SET, &offset);
     return ap_md5contextTo64(p, &context);