From: Graham Leggett Date: Fri, 3 Jul 2020 09:11:42 +0000 (+0000) Subject: Seek to the start of the file when calculating the ETag. X-Git-Tag: 2.5.0-alpha2-ci-test-only~1289 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=deb95b02c2e8edb4451f76eb9cd282f2dcf8ea9c;p=thirdparty%2Fapache%2Fhttpd.git Seek to the start of the file when calculating the ETag. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1879469 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/server/util_etag.c b/server/util_etag.c index 82517a36e94..e6ed53284fa 100644 --- a/server/util_etag.c +++ b/server/util_etag.c @@ -155,7 +155,7 @@ AP_DECLARE(char *) ap_make_etag_ex(request_rec *r, etag_rec *er) apr_file_t *fd = NULL; apr_size_t nbytes; - apr_off_t offset = 0; + apr_off_t offset = 0, zero = 0; apr_status_t status; if (er->fd) { @@ -185,6 +185,15 @@ AP_DECLARE(char *) ap_make_etag_ex(request_rec *r, etag_rec *er) return ""; } + if ((status = apr_file_seek(fd, APR_SET, &zero)) != APR_SUCCESS) { + ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO() + "Make etag: could not seek"); + if (er->pathname) { + apr_file_close(fd); + } + return ""; + } + apr_sha1_init(&context); nbytes = sizeof(buf); while ((status = apr_file_read(fd, buf, &nbytes)) == APR_SUCCESS) {