From b85fd593e08b8f27a18fb7e2feda02f01d9db15d Mon Sep 17 00:00:00 2001 From: Igor Sysoev Date: Tue, 23 Aug 2005 15:36:54 +0000 Subject: [PATCH] nginx-0.1.42-RELEASE import *) 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; the bug had appeared in 0.1.38. --- docs/xml/nginx/changes.xml | 29 ++++++++++++++ src/core/nginx.h | 2 +- src/event/ngx_event_timer.c | 2 +- src/http/ngx_http.h | 1 + src/http/ngx_http_core_module.c | 58 +++++++++++++++++----------- src/http/ngx_http_request.c | 3 -- src/http/ngx_http_request.h | 6 +-- src/http/ngx_http_script.c | 9 +++++ src/http/ngx_http_special_response.c | 2 +- src/os/unix/ngx_process_cycle.c | 2 +- 10 files changed, 81 insertions(+), 33 deletions(-) diff --git a/docs/xml/nginx/changes.xml b/docs/xml/nginx/changes.xml index 0dbd65260..9ba8ffa8d 100644 --- a/docs/xml/nginx/changes.xml +++ b/docs/xml/nginx/changes.xml @@ -9,6 +9,35 @@ nginx changelog + + + + +если URI запроса получался нулевой длины после обработки модулем +ngx_http_rewrite_module, то в модуле ngx_http_proxy_module происходил +segmentation fault или bus error. + + +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. + + + + + +директива limit_rate не работала внутри блока if; +ошибка появилась в 0.1.38. + + +the "limit_rate" directive did not work inside the "if" block; +bug appeared in 0.1.38. + + + + + + diff --git a/src/core/nginx.h b/src/core/nginx.h index 281036f33..8f0a36513 100644 --- 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 index 53bbc5f09..4d6c647da 100644 --- 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 index 2a62896c5..5be39363b 100644 --- a/src/http/ngx_http.h +++ b/src/http/ngx_http.h @@ -67,6 +67,7 @@ ngx_int_t ngx_http_parse_multi_header_lines(ngx_array_t *headers, 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 index cb7c9e8d0..852a9bbc0 100644 --- 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_request_t *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_request_t *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_request_t *r, 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 index 6c8bf2fa4..c6a580948 100644 --- 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 index d1ba774ef..2e8099102 100644 --- 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 index 716a6f054..27c9ce045 100644 --- 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_script_engine_t *e) 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_engine_t *e) 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 index 14d4c8022..ba3bfcbc6 100644 --- 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 index 9d0569411..0c8fdd27c 100644 --- 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 *cycle, ngx_uint_t priority) #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);