diff options
| author | Maxim Dounin <mdounin@mdounin.ru> | 2015-09-11 17:04:04 +0300 |
|---|---|---|
| committer | Maxim Dounin <mdounin@mdounin.ru> | 2015-09-11 17:04:04 +0300 |
| commit | 7930a6c44279315140955fac230cf5305fc3c550 (patch) | |
| tree | 34bc04caeccbc47691252f39347b238bb85e3070 /src/http/modules/ngx_http_rewrite_module.c | |
| parent | ce05841eefe0e6c5d18ae9b0fb8f9fbd7e99afdd (diff) | |
| download | nginx-7930a6c44279315140955fac230cf5305fc3c550.tar.gz nginx-7930a6c44279315140955fac230cf5305fc3c550.tar.bz2 | |
Fixed segfault with incorrect location nesting.
A configuration with a named location inside a zero-length prefix
or regex location used to trigger a segmentation fault, as
ngx_http_core_location() failed to properly detect if a nested location
was created. Example configuration to reproduce the problem:
location "" {
location @foo {}
}
Fix is to not rely on a parent location name length, but rather check
command type we are currently parsing.
Identical fix is also applied to ngx_http_rewrite_if(), which used to
incorrectly assume the "if" directive is on server{} level in such
locations.
Reported by Markus Linnala.
Found with afl-fuzz.
Diffstat (limited to 'src/http/modules/ngx_http_rewrite_module.c')
| -rw-r--r-- | src/http/modules/ngx_http_rewrite_module.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/http/modules/ngx_http_rewrite_module.c b/src/http/modules/ngx_http_rewrite_module.c index f24119645..754512fb1 100644 --- a/src/http/modules/ngx_http_rewrite_module.c +++ b/src/http/modules/ngx_http_rewrite_module.c @@ -612,7 +612,7 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) save = *cf; cf->ctx = ctx; - if (pclcf->name.len == 0) { + if (cf->cmd_type == NGX_HTTP_SRV_CONF) { if_code->loc_conf = NULL; cf->cmd_type = NGX_HTTP_SIF_CONF; |
