# HG changeset patch # User Igor Sysoev # Date 1124740800 -14400 # Node ID 991c6e4c76541232bb155a19db6e467ed134e909 # Parent 8216480b2a2ef16161119bacaabb60fd13563c3b nginx 0.1.42 *) Bugfix: if the request URI had a zero length after the processing in the ngx_http_proxy_module, then the segmentation fault or bus error occurred in the ngx_http_proxy_module. *) Bugfix: the "limit_rate" directive did not work inside the "if" block; bug appeared in 0.1.38. diff --git a/CHANGES b/CHANGES --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,13 @@ + +Changes with nginx 0.1.42 23 Aug 2005 + + *) Bugfix: if the request URI had a zero length after the processing in + the ngx_http_proxy_module, then the segmentation fault or bus error + occurred in the ngx_http_proxy_module. + + *) Bugfix: the "limit_rate" directive did not work inside the "if" + block; bug appeared in 0.1.38. + Changes with nginx 0.1.41 25 Jul 2005 diff --git a/CHANGES.ru b/CHANGES.ru --- a/CHANGES.ru +++ b/CHANGES.ru @@ -1,3 +1,13 @@ + +Изменения в nginx 0.1.42 23.08.2005 + + *) Исправление: если URI запроса получался нулевой длины после + обработки модулем ngx_http_rewrite_module, то в модуле + ngx_http_proxy_module происходил segmentation fault или bus error. + + *) Исправление: директива limit_rate не работала внутри блока if; + ошибка появилась в 0.1.38. + Изменения в nginx 0.1.41 25.07.2005 diff --git a/src/core/nginx.h b/src/core/nginx.h --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -8,7 +8,7 @@ #define _NGINX_H_INCLUDED_ -#define NGINX_VER "nginx/0.1.41" +#define NGINX_VER "nginx/0.1.42" #define NGINX_VAR "NGINX" #define NGX_NEWPID_EXT ".newbin" diff --git a/src/event/ngx_event_timer.c b/src/event/ngx_event_timer.c --- a/src/event/ngx_event_timer.c +++ b/src/event/ngx_event_timer.c @@ -67,7 +67,7 @@ ngx_event_find_timer(void) (node->key * NGX_TIMER_RESOLUTION - ngx_elapsed_msec); #endif - return timer > 0 ? timer: 0 ; + return timer > 0 ? timer : 0 ; } diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h --- a/src/http/ngx_http.h +++ b/src/http/ngx_http.h @@ -67,6 +67,7 @@ ngx_int_t ngx_http_parse_multi_header_li ngx_str_t *name, ngx_str_t *value); ngx_int_t ngx_http_find_server_conf(ngx_http_request_t *r); +void ngx_http_update_location_config(ngx_http_request_t *r); void ngx_http_handler(ngx_http_request_t *r); void ngx_http_finalize_request(ngx_http_request_t *r, ngx_int_t rc); diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -586,27 +586,7 @@ ngx_http_find_location_config(ngx_http_r return NGX_HTTP_NOT_FOUND; } - r->connection->log->file = clcf->err_log->file; - if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) { - r->connection->log->log_level = clcf->err_log->log_level; - } - - if ((ngx_io.flags & NGX_IO_SENDFILE) && clcf->sendfile) { - r->connection->sendfile = 1; - - } else { - r->connection->sendfile = 0; - } - - if (r->keepalive && clcf->keepalive_timeout == 0) { - r->keepalive = 0; - } - - if (!clcf->tcp_nopush) { - /* disable TCP_NOPUSH/TCP_CORK use */ - r->connection->tcp_nopush = NGX_TCP_NOPUSH_DISABLED; - } - + ngx_http_update_location_config(r); ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http cl:%z max:%uz", @@ -640,13 +620,43 @@ ngx_http_find_location_config(ngx_http_r return NGX_HTTP_MOVED_PERMANENTLY; } + return NGX_OK; +} + + +void +ngx_http_update_location_config(ngx_http_request_t *r) +{ + ngx_http_core_loc_conf_t *clcf; + + clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); + + r->connection->log->file = clcf->err_log->file; + if (!(r->connection->log->log_level & NGX_LOG_DEBUG_CONNECTION)) { + r->connection->log->log_level = clcf->err_log->log_level; + } + + if ((ngx_io.flags & NGX_IO_SENDFILE) && clcf->sendfile) { + r->connection->sendfile = 1; + + } else { + r->connection->sendfile = 0; + } + + if (r->keepalive && clcf->keepalive_timeout == 0) { + r->keepalive = 0; + } + + if (!clcf->tcp_nopush) { + /* disable TCP_NOPUSH/TCP_CORK use */ + r->connection->tcp_nopush = NGX_TCP_NOPUSH_DISABLED; + } + r->limit_rate = clcf->limit_rate; if (clcf->handler) { r->content_handler = clcf->handler; } - - return NGX_OK; } @@ -1072,6 +1082,8 @@ ngx_http_internal_redirect(ngx_http_requ cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); r->loc_conf = cscf->ctx->loc_conf; + ngx_http_update_location_config(r); + r->internal = 1; ngx_http_handler(r); diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -1696,9 +1696,6 @@ static ngx_int_t ngx_http_postponed_handler(ngx_http_request_t *r) { ngx_int_t rc; -#if 0 - ngx_http_request_t *mr; -#endif ngx_http_postponed_request_t *pr; ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -241,9 +241,9 @@ typedef struct { typedef struct ngx_http_postponed_request_s ngx_http_postponed_request_t; struct ngx_http_postponed_request_s { - ngx_http_request_t *request; - ngx_chain_t *out; - ngx_http_postponed_request_t *next; + ngx_http_request_t *request; + ngx_chain_t *out; + ngx_http_postponed_request_t *next; }; diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c --- a/src/http/ngx_http_script.c +++ b/src/http/ngx_http_script.c @@ -687,6 +687,14 @@ ngx_http_script_regex_end_code(ngx_http_ if (code->uri) { r->uri = e->buf; + if (r->uri.len == 0) { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + "the rewritten URI has a zero length"); + e->ip = ngx_http_script_exit; + e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; + return; + } + if (ngx_http_set_exten(r) != NGX_OK) { e->ip = ngx_http_script_exit; e->status = NGX_HTTP_INTERNAL_SERVER_ERROR; @@ -737,6 +745,7 @@ ngx_http_script_if_code(ngx_http_script_ if (e->sp->value) { if (code->loc_conf) { e->request->loc_conf = code->loc_conf; + ngx_http_update_location_config(e->request); } e->ip += sizeof(ngx_http_script_if_code_t); diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c --- a/src/http/ngx_http_special_response.c +++ b/src/http/ngx_http_special_response.c @@ -161,7 +161,7 @@ static char error_501_page[] = "" CRLF "501 Method Not Implemented" CRLF "" CRLF -"

500 Method Not Implemented

" CRLF +"

501 Method Not Implemented

" CRLF ; diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c --- a/src/os/unix/ngx_process_cycle.c +++ b/src/os/unix/ngx_process_cycle.c @@ -916,7 +916,7 @@ ngx_worker_process_init(ngx_cycle_t *cyc #endif if (ngx_add_channel_event(cycle, ngx_channel, NGX_READ_EVENT, - ngx_channel_handler) == NGX_ERROR) + ngx_channel_handler) == NGX_ERROR) { /* fatal */ exit(2);