about summary refs log tree commit diff
path: root/pkgs/servers/http/nginx
diff options
context:
space:
mode:
authorYegor Timoshenko <yegortimoshenko@riseup.net>2018-10-16 12:58:37 +0000
committeraszlig <aszlig@nix.build>2019-04-18 09:40:09 +0200
commitf03302b6362c8291b9390fb3aa6ee8f0d5098ec4 (patch)
tree914e46c860f0e49d94fe05a0e869b85fddd1724e /pkgs/servers/http/nginx
parent135d54f5358aaf2c71bea0a1ce3cdaaadb7a5222 (diff)
downloadnixlib-f03302b6362c8291b9390fb3aa6ee8f0d5098ec4.tar
nixlib-f03302b6362c8291b9390fb3aa6ee8f0d5098ec4.tar.gz
nixlib-f03302b6362c8291b9390fb3aa6ee8f0d5098ec4.tar.bz2
nixlib-f03302b6362c8291b9390fb3aa6ee8f0d5098ec4.tar.lz
nixlib-f03302b6362c8291b9390fb3aa6ee8f0d5098ec4.tar.xz
nixlib-f03302b6362c8291b9390fb3aa6ee8f0d5098ec4.tar.zst
nixlib-f03302b6362c8291b9390fb3aa6ee8f0d5098ec4.zip
nginx: check for realpath() == NULL in ETag patch
Thanks to Gabriel Ebner!
Diffstat (limited to 'pkgs/servers/http/nginx')
-rw-r--r--pkgs/servers/http/nginx/nix-etag-1.15.4.patch30
1 files changed, 16 insertions, 14 deletions
diff --git a/pkgs/servers/http/nginx/nix-etag-1.15.4.patch b/pkgs/servers/http/nginx/nix-etag-1.15.4.patch
index 7415b4e15d01..a4ee95076c1f 100644
--- a/pkgs/servers/http/nginx/nix-etag-1.15.4.patch
+++ b/pkgs/servers/http/nginx/nix-etag-1.15.4.patch
@@ -1,14 +1,14 @@
-From 3ed81ef9e973247d0c95bf240b3bd2e640f2605a Mon Sep 17 00:00:00 2001
+From a0ac82e4c79f359a7001a265cdb57e35978c6c23 Mon Sep 17 00:00:00 2001
 From: Yegor Timoshenko <yegortimoshenko@riseup.net>
 Date: Fri, 28 Sep 2018 03:27:04 +0000
 Subject: [PATCH] If root is in Nix store, set ETag to its path hash
 
 ---
- src/http/ngx_http_core_module.c | 56 +++++++++++++++++++++++++++------
- 1 file changed, 47 insertions(+), 9 deletions(-)
+ src/http/ngx_http_core_module.c | 55 +++++++++++++++++++++++++++++----
+ 1 file changed, 49 insertions(+), 6 deletions(-)
 
 diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
-index c57ec00c..d996d7e3 100644
+index c57ec00c..4eec7ec5 100644
 --- a/src/http/ngx_http_core_module.c
 +++ b/src/http/ngx_http_core_module.c
 @@ -1583,6 +1583,7 @@ ngx_http_set_etag(ngx_http_request_t *r)
@@ -19,17 +19,23 @@ index c57ec00c..d996d7e3 100644
  
      clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
  
-@@ -1598,16 +1599,53 @@ ngx_http_set_etag(ngx_http_request_t *r)
+@@ -1598,16 +1599,58 @@ ngx_http_set_etag(ngx_http_request_t *r)
      etag->hash = 1;
      ngx_str_set(&etag->key, "ETag");
  
 -    etag->value.data = ngx_pnalloc(r->pool, NGX_OFF_T_LEN + NGX_TIME_T_LEN + 3);
 -    if (etag->value.data == NULL) {
--        etag->hash = 0;
--        return NGX_ERROR;
--    }
 +    real = ngx_realpath(clcf->root.data, NULL);
 +
++    if (real == NULL) {
+         etag->hash = 0;
+         return NGX_ERROR;
+     }
+ 
+-    etag->value.len = ngx_sprintf(etag->value.data, "\"%xT-%xO\"",
+-                                  r->headers_out.last_modified_time,
+-                                  r->headers_out.content_length_n)
+-                      - etag->value.data;
 +    #define NIX_STORE_DIR "/nix/store"
 +    #define NIX_STORE_LEN ngx_strlen(NIX_STORE_DIR)
 +
@@ -50,11 +56,7 @@ index c57ec00c..d996d7e3 100644
 +
 +        *ptr2++ = '"';
 +        *ptr2 = '\0';
- 
--    etag->value.len = ngx_sprintf(etag->value.data, "\"%xT-%xO\"",
--                                  r->headers_out.last_modified_time,
--                                  r->headers_out.content_length_n)
--                      - etag->value.data;
++
 +        etag->value.len = ngx_strlen(ptr1);
 +        etag->value.data = ngx_pnalloc(r->pool, etag->value.len);
 +
@@ -83,5 +85,5 @@ index c57ec00c..d996d7e3 100644
      r->headers_out.etag = etag;
  
 -- 
-2.18.0
+2.19.0