]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Seek to the start of the file when calculating the ETag.
authorGraham Leggett <minfrin@apache.org>
Fri, 3 Jul 2020 09:11:42 +0000 (09:11 +0000)
committerGraham Leggett <minfrin@apache.org>
Fri, 3 Jul 2020 09:11:42 +0000 (09:11 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1879469 13f79535-47bb-0310-9956-ffa450edef68

server/util_etag.c

index 82517a36e948ec54845d635a87b2bb878676eae6..e6ed53284fa5e1242b970dcb1323c86ee968c108 100644 (file)
@@ -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) {