# HG changeset patch # User Igor Sysoev # Date 1335124800 -14400 # Node ID f41d4b305d226502ba55943330d21ffba4e562f5 # Parent 47cb3497fbaba2cdade5cb0c6312b07de5c3898f nginx 1.2.0 *) Bugfix: a segmentation fault might occur in a worker process if the "try_files" directive was used; the bug had appeared in 1.1.19. *) Bugfix: response might be truncated if there were more than IOV_MAX buffers used. *) Bugfix: in the "crop" parameter of the "image_filter" directive. Thanks to Maxim Bublis. diff --git a/CHANGES b/CHANGES --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,16 @@ +Changes with nginx 1.2.0 23 Apr 2012 + + *) Bugfix: a segmentation fault might occur in a worker process if the + "try_files" directive was used; the bug had appeared in 1.1.19. + + *) Bugfix: response might be truncated if there were more than IOV_MAX + buffers used. + + *) Bugfix: in the "crop" parameter of the "image_filter" directive. + Thanks to Maxim Bublis. + + Changes with nginx 1.1.19 12 Apr 2012 *) Security: specially crafted mp4 file might allow to overwrite memory diff --git a/CHANGES.ru b/CHANGES.ru --- a/CHANGES.ru +++ b/CHANGES.ru @@ -1,4 +1,16 @@ +Изменения в nginx 1.2.0 23.04.2012 + + *) Исправление: в рабочем процессе мог произойти segmentation fault, + если использовалась директива try_files; ошибка появилась в 1.1.19. + + *) Исправление: ответ мог быть передан не полностью, если использовалось + больше IOV_MAX буферов. + + *) Исправление: в работе параметра crop директивы image_filter. + Спасибо Maxim Bublis. + + Изменения в nginx 1.1.19 12.04.2012 *) Безопасность: при обработке специально созданного mp4 файла модулем diff --git a/src/core/nginx.c b/src/core/nginx.c --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -649,7 +649,7 @@ ngx_exec_new_binary(ngx_cycle_t *cycle, if (ngx_rename_file(ccf->oldpid.data, ccf->pid.data) != NGX_OK) { ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno, ngx_rename_file_n " %s back to %s failed after " - "the try to execute the new binary process \"%s\"", + "an attempt to execute new binary process \"%s\"", ccf->oldpid.data, ccf->pid.data, argv[0]); } } diff --git a/src/core/nginx.h b/src/core/nginx.h --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -9,8 +9,8 @@ #define _NGINX_H_INCLUDED_ -#define nginx_version 1001019 -#define NGINX_VERSION "1.1.19" +#define nginx_version 1002000 +#define NGINX_VERSION "1.2.0" #define NGINX_VER "nginx/" NGINX_VERSION #define NGINX_VAR "NGINX" diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -465,7 +465,7 @@ ngx_conf_read_token(ngx_conf_t *cf) if (cf->conf_file->file.offset >= file_size) { - if (cf->args->nelts > 0) { + if (cf->args->nelts > 0 || !last_space) { if (cf->conf_file->file.fd == NGX_INVALID_FILE) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, @@ -1481,7 +1481,8 @@ ngx_conf_check_num_bounds(ngx_conf_t *cf } ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "value must be equal or more than %i", bounds->low); + "value must be equal to or greater than %i", + bounds->low); return NGX_CONF_ERROR; } diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c --- a/src/core/ngx_string.c +++ b/src/core/ngx_string.c @@ -146,12 +146,12 @@ ngx_vslprintf(u_char *buf, u_char *last, { u_char *p, zero; int d; - double f, scale; + double f; size_t len, slen; int64_t i64; - uint64_t ui64; + uint64_t ui64, frac; ngx_msec_t ms; - ngx_uint_t width, sign, hex, max_width, frac_width, n; + ngx_uint_t width, sign, hex, max_width, frac_width, scale, n; ngx_str_t *v; ngx_variable_value_t *vv; @@ -365,28 +365,31 @@ ngx_vslprintf(u_char *buf, u_char *last, } ui64 = (int64_t) f; + frac = 0; + + if (frac_width) { + + scale = 1; + for (n = frac_width; n; n--) { + scale *= 10; + } + + frac = (uint64_t) ((f - (double) ui64) * scale + 0.5); + + if (frac == scale) { + ui64++; + frac = 0; + } + } buf = ngx_sprintf_num(buf, last, ui64, zero, 0, width); if (frac_width) { - if (buf < last) { *buf++ = '.'; } - scale = 1.0; - - for (n = frac_width; n; n--) { - scale *= 10.0; - } - - /* - * (int64_t) cast is required for msvc6: - * it cannot convert uint64_t to double - */ - ui64 = (uint64_t) ((f - (int64_t) ui64) * scale + 0.5); - - buf = ngx_sprintf_num(buf, last, ui64, '0', 0, frac_width); + buf = ngx_sprintf_num(buf, last, frac, '0', 0, frac_width); } fmt++; diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c --- a/src/event/ngx_event.c +++ b/src/event/ngx_event.c @@ -21,6 +21,7 @@ extern ngx_module_t ngx_rtsig_module; extern ngx_module_t ngx_select_module; +static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf); static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle); static ngx_int_t ngx_event_process_init(ngx_cycle_t *cycle); static char *ngx_events_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); @@ -31,8 +32,8 @@ static char *ngx_event_use(ngx_conf_t *c static char *ngx_event_debug_connection(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); -static void *ngx_event_create_conf(ngx_cycle_t *cycle); -static char *ngx_event_init_conf(ngx_cycle_t *cycle, void *conf); +static void *ngx_event_core_create_conf(ngx_cycle_t *cycle); +static char *ngx_event_core_init_conf(ngx_cycle_t *cycle, void *conf); static ngx_uint_t ngx_timer_resolution; @@ -93,7 +94,7 @@ static ngx_command_t ngx_events_command static ngx_core_module_t ngx_events_module_ctx = { ngx_string("events"), NULL, - NULL + ngx_event_init_conf }; @@ -173,8 +174,8 @@ static ngx_command_t ngx_event_core_com ngx_event_module_t ngx_event_core_module_ctx = { &event_core_name, - ngx_event_create_conf, /* create configuration */ - ngx_event_init_conf, /* init configuration */ + ngx_event_core_create_conf, /* create configuration */ + ngx_event_core_init_conf, /* init configuration */ { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } }; @@ -423,6 +424,19 @@ ngx_handle_write_event(ngx_event_t *wev, } +static char * +ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) +{ + if (ngx_get_conf(cycle->conf_ctx, ngx_events_module) == NULL) { + ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, + "no \"events\" section in configuration"); + return NGX_CONF_ERROR; + } + + return NGX_CONF_OK; +} + + static ngx_int_t ngx_event_module_init(ngx_cycle_t *cycle) { @@ -435,13 +449,6 @@ ngx_event_module_init(ngx_cycle_t *cycle ngx_event_conf_t *ecf; cf = ngx_get_conf(cycle->conf_ctx, ngx_events_module); - - if (cf == NULL) { - ngx_log_error(NGX_LOG_EMERG, cycle->log, 0, - "no \"events\" section in configuration"); - return NGX_ERROR; - } - ecf = (*cf)[ngx_event_core_module.ctx_index]; if (!ngx_test_config && ngx_process <= NGX_PROCESS_MASTER) { @@ -471,7 +478,7 @@ ngx_event_module_init(ngx_cycle_t *cycle (ngx_int_t) rlmt.rlim_cur : ccf->rlimit_nofile; ngx_log_error(NGX_LOG_WARN, cycle->log, 0, - "%ui worker_connections are more than " + "%ui worker_connections exceed " "open file resource limit: %i", ecf->connections, limit); } @@ -489,7 +496,7 @@ ngx_event_module_init(ngx_cycle_t *cycle } - /* cl should be equal or bigger than cache line size */ + /* cl should be equal to or greater than cache line size */ cl = 128; @@ -1116,7 +1123,7 @@ ngx_event_debug_connection(ngx_conf_t *c static void * -ngx_event_create_conf(ngx_cycle_t *cycle) +ngx_event_core_create_conf(ngx_cycle_t *cycle) { ngx_event_conf_t *ecf; @@ -1147,7 +1154,7 @@ ngx_event_create_conf(ngx_cycle_t *cycle static char * -ngx_event_init_conf(ngx_cycle_t *cycle, void *conf) +ngx_event_core_init_conf(ngx_cycle_t *cycle, void *conf) { ngx_event_conf_t *ecf = conf; diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c --- a/src/http/modules/ngx_http_fastcgi_module.c +++ b/src/http/modules/ngx_http_fastcgi_module.c @@ -1254,7 +1254,7 @@ ngx_http_fastcgi_process_header(ngx_http if (f->type == NGX_HTTP_FASTCGI_STDOUT && f->length == 0) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, - "upstream closed prematurely FastCGI stdout"); + "upstream prematurely closed FastCGI stdout"); return NGX_HTTP_UPSTREAM_INVALID_HEADER; } @@ -2198,8 +2198,8 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf if (conf->upstream.busy_buffers_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"fastcgi_busy_buffers_size\" must be equal or bigger than " - "maximum of the value of \"fastcgi_buffer_size\" and " + "\"fastcgi_busy_buffers_size\" must be equal to or greater than " + "the maximum of the value of \"fastcgi_buffer_size\" and " "one of the \"fastcgi_buffers\""); return NGX_CONF_ERROR; @@ -2229,8 +2229,8 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf if (conf->upstream.temp_file_write_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"fastcgi_temp_file_write_size\" must be equal or bigger than " - "maximum of the value of \"fastcgi_buffer_size\" and " + "\"fastcgi_temp_file_write_size\" must be equal to or greater " + "than the maximum of the value of \"fastcgi_buffer_size\" and " "one of the \"fastcgi_buffers\""); return NGX_CONF_ERROR; @@ -2253,8 +2253,8 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"fastcgi_max_temp_file_size\" must be equal to zero to disable " - "the temporary files usage or must be equal or bigger than " - "maximum of the value of \"fastcgi_buffer_size\" and " + "temporary files usage or must be equal to or greater than " + "the maximum of the value of \"fastcgi_buffer_size\" and " "one of the \"fastcgi_buffers\""); return NGX_CONF_ERROR; diff --git a/src/http/modules/ngx_http_geo_module.c b/src/http/modules/ngx_http_geo_module.c --- a/src/http/modules/ngx_http_geo_module.c +++ b/src/http/modules/ngx_http_geo_module.c @@ -566,7 +566,7 @@ ngx_http_geo_range(ngx_conf_t *cf, ngx_h if (ctx->binary_include) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "binary geo range base \"%s\" may not be mixed with usual entries", + "binary geo range base \"%s\" cannot be mixed with usual entries", ctx->include_name.data); return NGX_CONF_ERROR; } @@ -1195,7 +1195,7 @@ ngx_http_geo_include_binary_base(ngx_con if (ctx->outside_entries) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "binary geo range base \"%s\" may not be mixed with usual entries", + "binary geo range base \"%s\" cannot be mixed with usual entries", name->data); rc = NGX_ERROR; goto done; @@ -1203,7 +1203,7 @@ ngx_http_geo_include_binary_base(ngx_con if (ctx->binary_include) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "second binary geo range base \"%s\" may not be mixed with \"%s\"", + "second binary geo range base \"%s\" cannot be mixed with \"%s\"", name->data, ctx->include_name.data); rc = NGX_ERROR; goto done; diff --git a/src/http/modules/ngx_http_image_filter_module.c b/src/http/modules/ngx_http_image_filter_module.c --- a/src/http/modules/ngx_http_image_filter_module.c +++ b/src/http/modules/ngx_http_image_filter_module.c @@ -817,9 +817,7 @@ transparent: resize = 0; - if ((ngx_uint_t) (dx * 100 / dy) - < ctx->max_width * 100 / ctx->max_height) - { + if ((double) dx / dy < (double) ctx->max_width / ctx->max_height) { if ((ngx_uint_t) dx > ctx->max_width) { dy = dy * ctx->max_width / dx; dy = dy ? dy : 1; diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -1497,6 +1497,10 @@ ngx_http_proxy_input_filter_init(void *d u = r->upstream; ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); + if (ctx == NULL) { + return NGX_ERROR; + } + ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http proxy filter init s:%d h:%d c:%d l:%O", u->headers_in.status_n, ctx->head, u->headers_in.chunked, @@ -1636,6 +1640,11 @@ ngx_http_proxy_parse_chunked(ngx_http_re } state; ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); + + if (ctx == NULL) { + return NGX_ERROR; + } + state = ctx->state; if (state == sw_chunk_data && ctx->size == 0) { @@ -1883,6 +1892,10 @@ ngx_http_proxy_chunked_filter(ngx_event_ r = p->input_ctx; ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); + if (ctx == NULL) { + return NGX_ERROR; + } + b = NULL; prev = &buf->shadow; @@ -2064,6 +2077,11 @@ ngx_http_proxy_non_buffered_chunked_filt ngx_http_proxy_ctx_t *ctx; ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); + + if (ctx == NULL) { + return NGX_ERROR; + } + u = r->upstream; buf = &u->buffer; @@ -2734,8 +2752,8 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t if (conf->upstream.busy_buffers_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"proxy_busy_buffers_size\" must be equal or bigger than " - "maximum of the value of \"proxy_buffer_size\" and " + "\"proxy_busy_buffers_size\" must be equal to or greater than " + "the maximum of the value of \"proxy_buffer_size\" and " "one of the \"proxy_buffers\""); return NGX_CONF_ERROR; @@ -2765,8 +2783,8 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t if (conf->upstream.temp_file_write_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"proxy_temp_file_write_size\" must be equal or bigger than " - "maximum of the value of \"proxy_buffer_size\" and " + "\"proxy_temp_file_write_size\" must be equal to or greater " + "than the maximum of the value of \"proxy_buffer_size\" and " "one of the \"proxy_buffers\""); return NGX_CONF_ERROR; @@ -2788,8 +2806,8 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"proxy_max_temp_file_size\" must be equal to zero to disable " - "the temporary files usage or must be equal or bigger than " - "maximum of the value of \"proxy_buffer_size\" and " + "temporary files usage or must be equal to or greater than " + "the maximum of the value of \"proxy_buffer_size\" and " "one of the \"proxy_buffers\""); return NGX_CONF_ERROR; @@ -3425,11 +3443,11 @@ ngx_http_proxy_pass(ngx_conf_t *cf, ngx_ { if (plcf->vars.uri.len) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"proxy_pass\" may not have URI part in " + "\"proxy_pass\" cannot have URI part in " "location given by regular expression, " "or inside named location, " - "or inside the \"if\" statement, " - "or inside the \"limit_except\" block"); + "or inside \"if\" statement, " + "or inside \"limit_except\" block"); return NGX_CONF_ERROR; } @@ -3498,14 +3516,14 @@ ngx_http_proxy_redirect(ngx_conf_t *cf, if (ngx_strcmp(value[1].data, "default") == 0) { if (plcf->proxy_lengths) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"proxy_redirect default\" may not be used " + "\"proxy_redirect default\" cannot be used " "with \"proxy_pass\" directive with variables"); return NGX_CONF_ERROR; } if (plcf->url.data == NULL) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"proxy_redirect default\" must go " + "\"proxy_redirect default\" should be placed " "after the \"proxy_pass\" directive"); return NGX_CONF_ERROR; } diff --git a/src/http/modules/ngx_http_scgi_module.c b/src/http/modules/ngx_http_scgi_module.c --- a/src/http/modules/ngx_http_scgi_module.c +++ b/src/http/modules/ngx_http_scgi_module.c @@ -1173,8 +1173,8 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t if (conf->upstream.busy_buffers_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"scgi_busy_buffers_size\" must be equal or bigger " - "than maximum of the value of \"scgi_buffer_size\" and " + "\"scgi_busy_buffers_size\" must be equal to or greater " + "than the maximum of the value of \"scgi_buffer_size\" and " "one of the \"scgi_buffers\""); return NGX_CONF_ERROR; @@ -1204,8 +1204,8 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t if (conf->upstream.temp_file_write_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"scgi_temp_file_write_size\" must be equal or bigger than " - "maximum of the value of \"scgi_buffer_size\" and " + "\"scgi_temp_file_write_size\" must be equal to or greater than " + "the maximum of the value of \"scgi_buffer_size\" and " "one of the \"scgi_buffers\""); return NGX_CONF_ERROR; @@ -1227,8 +1227,8 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t && conf->upstream.max_temp_file_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"scgi_max_temp_file_size\" must be equal to zero to disable " - "the temporary files usage or must be equal or bigger than " - "maximum of the value of \"scgi_buffer_size\" and " + "temporary files usage or must be equal to or greater than " + "the maximum of the value of \"scgi_buffer_size\" and " "one of the \"scgi_buffers\""); return NGX_CONF_ERROR; diff --git a/src/http/modules/ngx_http_split_clients_module.c b/src/http/modules/ngx_http_split_clients_module.c --- a/src/http/modules/ngx_http_split_clients_module.c +++ b/src/http/modules/ngx_http_split_clients_module.c @@ -177,7 +177,7 @@ ngx_conf_split_clients_block(ngx_conf_t sum = part[i].percent ? sum + part[i].percent : 10000; if (sum > 10000) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "percent sum is more than 100%%"); + "percent total is greater than 100%%"); return NGX_CONF_ERROR; } diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c --- a/src/http/modules/ngx_http_ssi_filter_module.c +++ b/src/http/modules/ngx_http_ssi_filter_module.c @@ -2003,7 +2003,7 @@ ngx_http_ssi_include(ngx_http_request_t if (set && stub) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, - "\"set\" and \"stub\" may not be used together " + "\"set\" and \"stub\" cannot be used together " "in \"include\" SSI command"); return NGX_HTTP_SSI_ERROR; } @@ -2011,7 +2011,7 @@ ngx_http_ssi_include(ngx_http_request_t if (wait) { if (uri == NULL) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, - "\"wait\" may not be used with file=\"%V\"", file); + "\"wait\" cannot be used with file=\"%V\"", file); return NGX_HTTP_SSI_ERROR; } @@ -2188,7 +2188,7 @@ ngx_http_ssi_include(ngx_http_request_t } else { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, - "only one subrequest may be waited at the same time"); + "can only wait for one subrequest at a time"); } return NGX_OK; diff --git a/src/http/modules/ngx_http_uwsgi_module.c b/src/http/modules/ngx_http_uwsgi_module.c --- a/src/http/modules/ngx_http_uwsgi_module.c +++ b/src/http/modules/ngx_http_uwsgi_module.c @@ -1216,8 +1216,8 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t if (conf->upstream.busy_buffers_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"uwsgi_busy_buffers_size\" must be equal or bigger " - "than maximum of the value of \"uwsgi_buffer_size\" and " + "\"uwsgi_busy_buffers_size\" must be equal to or greater " + "than the maximum of the value of \"uwsgi_buffer_size\" and " "one of the \"uwsgi_buffers\""); return NGX_CONF_ERROR; @@ -1247,8 +1247,8 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t if (conf->upstream.temp_file_write_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, - "\"uwsgi_temp_file_write_size\" must be equal or bigger than " - "maximum of the value of \"uwsgi_buffer_size\" and " + "\"uwsgi_temp_file_write_size\" must be equal to or greater than " + "the maximum of the value of \"uwsgi_buffer_size\" and " "one of the \"uwsgi_buffers\""); return NGX_CONF_ERROR; @@ -1270,8 +1270,8 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t && conf->upstream.max_temp_file_size < size) { ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "\"uwsgi_max_temp_file_size\" must be equal to zero to disable " - "the temporary files usage or must be equal or bigger than " - "maximum of the value of \"uwsgi_buffer_size\" and " + "temporary files usage or must be equal to or greater than " + "the maximum of the value of \"uwsgi_buffer_size\" and " "one of the \"uwsgi_buffers\""); return NGX_CONF_ERROR; diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm --- a/src/http/modules/perl/nginx.pm +++ b/src/http/modules/perl/nginx.pm @@ -50,7 +50,7 @@ our @EXPORT = qw( HTTP_INSUFFICIENT_STORAGE ); -our $VERSION = '1.1.19'; +our $VERSION = '1.2.0'; require XSLoader; XSLoader::load('nginx', $VERSION); 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 @@ -1240,7 +1240,7 @@ ngx_http_core_try_files_phase(ngx_http_r reserve = len > r->uri.len - alias ? len - (r->uri.len - alias) : 0; } - if (reserve > allocated) { + if (reserve > allocated || !allocated) { /* 16 bytes are preallocation */ allocated = reserve + 16; 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 @@ -612,6 +612,8 @@ ngx_http_ssl_handshake_handler(ngx_conne c->ssl->no_wait_shutdown = 1; + c->log->action = "reading client request line"; + c->read->handler = ngx_http_process_request_line; /* STUB: epoll edge */ c->write->handler = ngx_http_empty_handler; @@ -1175,7 +1177,7 @@ ngx_http_read_request_header(ngx_http_re if (n == 0) { ngx_log_error(NGX_LOG_INFO, c->log, 0, - "client closed prematurely connection"); + "client prematurely closed connection"); } if (n == 0 || n == NGX_ERROR) { @@ -2426,7 +2428,7 @@ closed: } ngx_log_error(NGX_LOG_INFO, c->log, err, - "client closed prematurely connection"); + "client prematurely closed connection"); ngx_http_finalize_request(r, 0); } diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c --- a/src/http/ngx_http_request_body.c +++ b/src/http/ngx_http_request_body.c @@ -303,7 +303,7 @@ ngx_http_do_read_client_request_body(ngx if (n == 0) { ngx_log_error(NGX_LOG_INFO, c->log, 0, - "client closed prematurely connection"); + "client prematurely closed connection"); } if (n == 0 || n == NGX_ERROR) { diff --git a/src/os/unix/ngx_darwin_sendfile_chain.c b/src/os/unix/ngx_darwin_sendfile_chain.c --- a/src/os/unix/ngx_darwin_sendfile_chain.c +++ b/src/os/unix/ngx_darwin_sendfile_chain.c @@ -103,10 +103,8 @@ ngx_darwin_sendfile_chain(ngx_connection prev = NULL; iov = NULL; - for (cl = in; - cl && header.nelts < IOV_MAX && send < limit; - cl = cl->next) - { + for (cl = in; cl && send < limit; cl = cl->next) { + if (ngx_buf_special(cl->buf)) { continue; } @@ -125,6 +123,10 @@ ngx_darwin_sendfile_chain(ngx_connection iov->iov_len += (size_t) size; } else { + if (header.nelts >= IOV_MAX) { + break; + } + iov = ngx_array_push(&header); if (iov == NULL) { return NGX_CHAIN_ERROR; @@ -178,7 +180,7 @@ ngx_darwin_sendfile_chain(ngx_connection prev = NULL; iov = NULL; - while (cl && header.nelts < IOV_MAX && send < limit) { + while (cl && send < limit) { if (ngx_buf_special(cl->buf)) { cl = cl->next; @@ -199,6 +201,10 @@ ngx_darwin_sendfile_chain(ngx_connection iov->iov_len += (size_t) size; } else { + if (trailer.nelts >= IOV_MAX) { + break; + } + iov = ngx_array_push(&trailer); if (iov == NULL) { return NGX_CHAIN_ERROR; diff --git a/src/os/unix/ngx_freebsd_sendfile_chain.c b/src/os/unix/ngx_freebsd_sendfile_chain.c --- a/src/os/unix/ngx_freebsd_sendfile_chain.c +++ b/src/os/unix/ngx_freebsd_sendfile_chain.c @@ -107,10 +107,8 @@ ngx_freebsd_sendfile_chain(ngx_connectio prev = NULL; iov = NULL; - for (cl = in; - cl && header.nelts < IOV_MAX && send < limit; - cl = cl->next) - { + for (cl = in; cl && send < limit; cl = cl->next) { + if (ngx_buf_special(cl->buf)) { continue; } @@ -129,6 +127,10 @@ ngx_freebsd_sendfile_chain(ngx_connectio iov->iov_len += (size_t) size; } else { + if (header.nelts >= IOV_MAX){ + break; + } + iov = ngx_array_push(&header); if (iov == NULL) { return NGX_CHAIN_ERROR; @@ -183,7 +185,7 @@ ngx_freebsd_sendfile_chain(ngx_connectio prev = NULL; iov = NULL; - while (cl && header.nelts < IOV_MAX && send < limit) { + while (cl && send < limit) { if (ngx_buf_special(cl->buf)) { cl = cl->next; @@ -204,6 +206,10 @@ ngx_freebsd_sendfile_chain(ngx_connectio iov->iov_len += (size_t) size; } else { + if (trailer.nelts >= IOV_MAX){ + break; + } + iov = ngx_array_push(&trailer); if (iov == NULL) { return NGX_CHAIN_ERROR; diff --git a/src/os/unix/ngx_linux_sendfile_chain.c b/src/os/unix/ngx_linux_sendfile_chain.c --- a/src/os/unix/ngx_linux_sendfile_chain.c +++ b/src/os/unix/ngx_linux_sendfile_chain.c @@ -89,10 +89,8 @@ ngx_linux_sendfile_chain(ngx_connection_ /* create the iovec and coalesce the neighbouring bufs */ - for (cl = in; - cl && header.nelts < IOV_MAX && send < limit; - cl = cl->next) - { + for (cl = in; cl && send < limit; cl = cl->next) { + if (ngx_buf_special(cl->buf)) { continue; } @@ -132,6 +130,10 @@ ngx_linux_sendfile_chain(ngx_connection_ iov->iov_len += (size_t) size; } else { + if (header.nelts >= IOV_MAX) { + break; + } + iov = ngx_array_push(&header); if (iov == NULL) { return NGX_CHAIN_ERROR; diff --git a/src/os/unix/ngx_readv_chain.c b/src/os/unix/ngx_readv_chain.c --- a/src/os/unix/ngx_readv_chain.c +++ b/src/os/unix/ngx_readv_chain.c @@ -71,6 +71,10 @@ ngx_readv_chain(ngx_connection_t *c, ngx iov->iov_len += chain->buf->end - chain->buf->last; } else { + if (vec.nelts >= IOV_MAX) { + break; + } + iov = ngx_array_push(&vec); if (iov == NULL) { return NGX_ERROR; @@ -195,6 +199,10 @@ ngx_readv_chain(ngx_connection_t *c, ngx iov->iov_len += chain->buf->end - chain->buf->last; } else { + if (vec.nelts >= IOV_MAX) { + break; + } + iov = ngx_array_push(&vec); if (iov == NULL) { return NGX_ERROR; diff --git a/src/os/unix/ngx_solaris_sendfilev_chain.c b/src/os/unix/ngx_solaris_sendfilev_chain.c --- a/src/os/unix/ngx_solaris_sendfilev_chain.c +++ b/src/os/unix/ngx_solaris_sendfilev_chain.c @@ -74,7 +74,6 @@ ngx_solaris_sendfilev_chain(ngx_connecti send = 0; - complete = 0; vec.elts = sfvs; vec.size = sizeof(sendfilevec_t); @@ -87,6 +86,7 @@ ngx_solaris_sendfilev_chain(ngx_connecti fprev = 0; sfv = NULL; eintr = 0; + complete = 0; sent = 0; prev_send = send; @@ -94,8 +94,8 @@ ngx_solaris_sendfilev_chain(ngx_connecti /* create the sendfilevec and coalesce the neighbouring bufs */ - for (cl = in; cl && vec.nelts < IOV_MAX && send < limit; cl = cl->next) - { + for (cl = in; cl && send < limit; cl = cl->next) { + if (ngx_buf_special(cl->buf)) { continue; } @@ -113,6 +113,10 @@ ngx_solaris_sendfilev_chain(ngx_connecti sfv->sfv_len += (size_t) size; } else { + if (vec.nelts >= IOV_MAX) { + break; + } + sfv = ngx_array_push(&vec); if (sfv == NULL) { return NGX_CHAIN_ERROR; @@ -147,6 +151,10 @@ ngx_solaris_sendfilev_chain(ngx_connecti sfv->sfv_len += (size_t) size; } else { + if (vec.nelts >= IOV_MAX) { + break; + } + sfv = ngx_array_push(&vec); if (sfv == NULL) { return NGX_CHAIN_ERROR; diff --git a/src/os/unix/ngx_writev_chain.c b/src/os/unix/ngx_writev_chain.c --- a/src/os/unix/ngx_writev_chain.c +++ b/src/os/unix/ngx_writev_chain.c @@ -54,7 +54,6 @@ ngx_writev_chain(ngx_connection_t *c, ng } send = 0; - complete = 0; vec.elts = iovs; vec.size = sizeof(struct iovec); @@ -65,14 +64,15 @@ ngx_writev_chain(ngx_connection_t *c, ng prev = NULL; iov = NULL; eintr = 0; + complete = 0; prev_send = send; vec.nelts = 0; /* create the iovec and coalesce the neighbouring bufs */ - for (cl = in; cl && vec.nelts < IOV_MAX && send < limit; cl = cl->next) - { + for (cl = in; cl && send < limit; cl = cl->next) { + if (ngx_buf_special(cl->buf)) { continue; } @@ -93,6 +93,10 @@ ngx_writev_chain(ngx_connection_t *c, ng iov->iov_len += size; } else { + if (vec.nelts >= IOV_MAX) { + break; + } + iov = ngx_array_push(&vec); if (iov == NULL) { return NGX_CHAIN_ERROR;