diff options
author | Igor Sysoev <igor@sysoev.ru> | 2007-02-09 11:56:23 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2007-02-09 11:56:23 +0000 |
commit | f0b150faf8c951e7c791f2d19b63461f36438c3e (patch) | |
tree | 2c242b314273040d138b1e62d8595ef0597d0a5c /src/http/modules/ngx_http_fastcgi_module.c | |
parent | e980185ee00005f0570a95dd5f9cb6f79fed3b04 (diff) | |
download | nginx-f0b150faf8c951e7c791f2d19b63461f36438c3e.tar.gz nginx-f0b150faf8c951e7c791f2d19b63461f36438c3e.zip |
fix segfault when $fastcgi_script_name is used in access_log
and there was bad request (400)
Diffstat (limited to 'src/http/modules/ngx_http_fastcgi_module.c')
-rw-r--r-- | src/http/modules/ngx_http_fastcgi_module.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c index f4c0caf02..bf104d74b 100644 --- a/src/http/modules/ngx_http_fastcgi_module.c +++ b/src/http/modules/ngx_http_fastcgi_module.c @@ -1969,27 +1969,38 @@ ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r, u_char *p; ngx_http_fastcgi_loc_conf_t *flcf; - v->valid = 1; - v->no_cachable = 0; - v->not_found = 0; + if (r->uri.len) { + v->valid = 1; + v->no_cachable = 0; + v->not_found = 0; - flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); + flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module); - if (r->uri.data[r->uri.len - 1] != '/') { - v->len = r->uri.len; - v->data = r->uri.data; - return NGX_OK; - } + if (r->uri.data[r->uri.len - 1] != '/') { + v->len = r->uri.len; + v->data = r->uri.data; + return NGX_OK; + } - v->len = r->uri.len + flcf->index.len; + v->len = r->uri.len + flcf->index.len; - v->data = ngx_palloc(r->pool, v->len); - if (v->data == NULL) { - return NGX_ERROR; - } + v->data = ngx_palloc(r->pool, v->len); + if (v->data == NULL) { + return NGX_ERROR; + } - p = ngx_copy(v->data, r->uri.data, r->uri.len); - ngx_memcpy(p, flcf->index.data, flcf->index.len); + p = ngx_copy(v->data, r->uri.data, r->uri.len); + ngx_memcpy(p, flcf->index.data, flcf->index.len); + + } else { + v->len = 0; + v->valid = 1; + v->no_cachable = 0; + v->not_found = 0; + v->data = NULL; + + return NGX_OK; + } return NGX_OK; } |