[PATCH] Cache: status must be less then 599 in *_cache_valid directives.

Maxim Dounin mdounin at mdounin.ru
Mon Sep 24 18:00:01 UTC 2018


Hello!

On Mon, Sep 24, 2018 at 08:34:37PM +0300, Gena Makhomed wrote:

> On 24.09.2018 19:25, Maxim Dounin wrote:
> 
> >> What about adding 307 and 308 to list of default response codes?
> 
> > I'm not a fan of the "proxy_cache_valid 5m" form for the very same
> > reasons, and would rather avoid changing it.
> 
> Ok. What about more strict check for invalid status codes?
> 
> # HG changeset patch
> # User Gena Makhomed <gmm at csdoc.com>
> # Date 1537810006 -10800
> #      Mon Sep 24 20:26:46 2018 +0300
> # Node ID fc6c7e03edaad907d6a85afab009cb5c1fa43c56
> # Parent  17092295247709a533acca09f990c13337a24948
> Cache: status must be less then 599 in *_cache_valid directives.
> 
> Previously, configurations with typo, for example
> 
>      fastcgi_cache_valid 200301 302 5m;
> 
> successfully pass configuration test. Adding check for status
> codes > 599, and such configurations are now properly rejected.

Have you seen such configurations in the real life, or it is 
something made-up while looking at the code?

> 
> diff -r 170922952477 -r fc6c7e03edaa src/http/ngx_http_file_cache.c
> --- a/src/http/ngx_http_file_cache.c	Wed Sep 19 09:26:47 2018 -0500
> +++ b/src/http/ngx_http_file_cache.c	Mon Sep 24 20:26:46 2018 +0300
> @@ -2669,7 +2669,7 @@
>           } else {
> 
>               status = ngx_atoi(value[i].data, value[i].len);
> -            if (status < 100) {
> +            if (status < 100 || status > 599) {
>                   ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
>                                      "invalid status \"%V\"", &value[i]);
>                   return NGX_CONF_ERROR;
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx-devel mailing list