From: Ruslan Ermilov Date: Mon, 16 Dec 2019 12:19:01 +0000 (+0300) Subject: Rewrite: disallow empty replacements. X-Git-Tag: release-1.17.7~7 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=4c031f9a6a879bcc4e86f5b7d4177996c9bca4cd;p=nginx.git 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. --- 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];