* 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
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);