aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_rewrite_module.c
diff options
context:
space:
mode:
authorRuslan Ermilov <ru@nginx.com>2019-12-16 15:19:01 +0300
committerRuslan Ermilov <ru@nginx.com>2019-12-16 15:19:01 +0300
commit4c031f9a6a879bcc4e86f5b7d4177996c9bca4cd (patch)
tree4fe3659398eb0ab9cac080ba15e644631c4abb35 /src/http/modules/ngx_http_rewrite_module.c
parenta5895eb502747f396d3901a948834cd87d5fb0c3 (diff)
downloadnginx-4c031f9a6a879bcc4e86f5b7d4177996c9bca4cd.tar.gz
nginx-4c031f9a6a879bcc4e86f5b7d4177996c9bca4cd.zip
Rewrite: disallow empty replacements.
While empty replacements were caught at run-time, parsing code of the "rewrite" directive expects that a minimum length of the "replacement" argument is 1.
Diffstat (limited to 'src/http/modules/ngx_http_rewrite_module.c')
-rw-r--r--src/http/modules/ngx_http_rewrite_module.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/http/modules/ngx_http_rewrite_module.c b/src/http/modules/ngx_http_rewrite_module.c
index 3b49c455c..0e6d4df64 100644
--- a/src/http/modules/ngx_http_rewrite_module.c
+++ b/src/http/modules/ngx_http_rewrite_module.c
@@ -318,6 +318,11 @@ ngx_http_rewrite(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
value = cf->args->elts;
+ if (value[2].len == 0) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "empty replacement");
+ return NGX_CONF_ERROR;
+ }
+
ngx_memzero(&rc, sizeof(ngx_regex_compile_t));
rc.pattern = value[1];