]> git.kaiwu.me - nginx.git/commitdiff
Capped the status code that may be returned with "return" and "try_files".
authorRuslan Ermilov <ru@nginx.com>
Wed, 16 May 2012 13:22:03 +0000 (13:22 +0000)
committerRuslan Ermilov <ru@nginx.com>
Wed, 16 May 2012 13:22:03 +0000 (13:22 +0000)
src/http/modules/ngx_http_rewrite_module.c
src/http/ngx_http_core_module.c

index 74d26e524f480aab10922252a0048e3b09d4d349..4081f87743343c775c9901e522d27553bd76a4cb 100644 (file)
@@ -485,6 +485,12 @@ ngx_http_rewrite_return(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
     } else {
 
+        if (ret->status > 999) {
+            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                               "invalid return code \"%V\"", &value[1]);
+            return NGX_CONF_ERROR;
+        }
+
         if (cf->args->nelts == 2) {
             return NGX_CONF_OK;
         }
index 31832ceb8e69b62c36da5923413efca5df0c141c..5bb01d9ea770a987397390490d71fc20c9a34109 100644 (file)
@@ -4662,7 +4662,7 @@ ngx_http_core_try_files(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
         code = ngx_atoi(tf[i - 1].name.data + 1, tf[i - 1].name.len - 2);
 
-        if (code == NGX_ERROR) {
+        if (code == NGX_ERROR || code > 999) {
             ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
                                "invalid code \"%*s\"",
                                tf[i - 1].name.len - 1, tf[i - 1].name.data);