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.
This commit is contained in:
Ruslan Ermilov 2019-12-16 15:19:01 +03:00
parent b44253a3bc
commit b26e64492b

View file

@ -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];