]> git.kaiwu.me - nginx.git/commitdiff
Cache: fixed cache valid slot to reject incorrect statuses.
authorMaxim Dounin <mdounin@mdounin.ru>
Wed, 18 Apr 2018 13:11:41 +0000 (16:11 +0300)
committerMaxim Dounin <mdounin@mdounin.ru>
Wed, 18 Apr 2018 13:11:41 +0000 (16:11 +0300)
Previously, result of ngx_atoi() was assigned to an ngx_uint_t variable,
and errors reported by ngx_atoi() became positive, so the following check
in "status < 100" failed to catch them.  This resulted in the configurations
like "proxy_cache_valid 2xx 30s" being accepted as correct, while they
in fact do nothing.  Changing type to ngx_int_t fixes this, and such
configurations are now properly rejected.

src/http/ngx_http_file_cache.c

index 3b2b68a260183b5d91332558ba448591a41daf40..56866fa4e1183f7fc45845ba3510746189da0cb1 100644 (file)
@@ -2620,7 +2620,8 @@ ngx_http_file_cache_valid_set_slot(ngx_conf_t *cf, ngx_command_t *cmd,
 
     time_t                    valid;
     ngx_str_t                *value;
-    ngx_uint_t                i, n, status;
+    ngx_int_t                 status;
+    ngx_uint_t                i, n;
     ngx_array_t             **a;
     ngx_http_cache_valid_t   *v;
     static ngx_uint_t         statuses[] = { 200, 301, 302 };