diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2015-08-16 10:51:16 +0300 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2015-08-16 10:51:16 +0300 |
commit | f178835bfa2f59c59186c9ffa967d412df7f2339 (patch) | |
tree | 2a56a3daeefa4937ed9a6ccd7ce0cf8ccfc50d63 | |
parent | 26e32aaa9c023dbfae46dfee5e2b26001f6fda44 (diff) | |
download | nginx-f178835bfa2f59c59186c9ffa967d412df7f2339.tar.gz |
Fixed segfault with try_files introduced by c985d90a8d1f.
If alias was used in a location given by a regular expression,
nginx used to do wrong thing in try_files if a location name (i.e.,
regular expression) was an exact prefix of URI. The following
configuration triggered a segmentation fault on a request to "/mail":
location ~ /mail {
alias /path/to/directory;
try_files $uri =404;
}
Reported by Per Hansson.
-rw-r--r-- | src/http/ngx_http_core_module.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 096a561c4..9d502acf5 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -1272,7 +1272,9 @@ ngx_http_core_try_files_phase(ngx_http_request_t *r, *e.pos = '\0'; - if (alias && ngx_strncmp(name, clcf->name.data, alias) == 0) { + if (alias && alias != NGX_MAX_SIZE_T_VALUE + && ngx_strncmp(name, clcf->name.data, alias) == 0) + { ngx_memmove(name, name + alias, len - alias); path.len -= alias; } |