From deb95b02c2e8edb4451f76eb9cd282f2dcf8ea9c Mon Sep 17 00:00:00 2001 From: Graham Leggett Date: Fri, 3 Jul 2020 09:11:42 +0000 Subject: [PATCH] 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 --- server/util_etag.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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) { -- 2.47.3