diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/nginx.c | 10 | ||||
-rw-r--r-- | src/core/nginx.h | 2 | ||||
-rw-r--r-- | src/core/ngx_conf_file.c | 2 | ||||
-rw-r--r-- | src/core/ngx_config.h | 4 | ||||
-rw-r--r-- | src/core/ngx_connection.h | 4 | ||||
-rw-r--r-- | src/core/ngx_cycle.c | 2 | ||||
-rw-r--r-- | src/core/ngx_file.c | 14 | ||||
-rw-r--r-- | src/core/ngx_file.h | 4 | ||||
-rw-r--r-- | src/core/ngx_garbage_collector.c | 1 | ||||
-rw-r--r-- | src/core/ngx_inet.c | 5 | ||||
-rw-r--r-- | src/core/ngx_log.c | 2 | ||||
-rw-r--r-- | src/core/ngx_output_chain.c | 4 | ||||
-rw-r--r-- | src/core/ngx_string.c | 2 | ||||
-rw-r--r-- | src/core/ngx_times.c | 38 | ||||
-rw-r--r-- | src/core/ngx_unix_domain.c | 2 | ||||
-rw-r--r-- | src/http/modules/ngx_http_proxy_module.c | 6 | ||||
-rw-r--r-- | src/http/modules/ngx_http_rewrite_module.c | 8 | ||||
-rw-r--r-- | src/http/ngx_http_header_filter_module.c | 53 | ||||
-rw-r--r-- | src/http/ngx_http_script.c | 5 | ||||
-rw-r--r-- | src/http/ngx_http_script.h | 9 | ||||
-rw-r--r-- | src/os/unix/ngx_errno.h | 2 | ||||
-rw-r--r-- | src/os/unix/ngx_time.c | 6 | ||||
-rw-r--r-- | src/os/unix/ngx_time.h | 6 |
23 files changed, 122 insertions, 69 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index bb6f093e4..7b98e1263 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -440,7 +440,7 @@ ngx_save_argv(ngx_cycle_t *cycle, int argc, char *const *argv) return NGX_ERROR; } - ngx_cpystrn((u_char *) ngx_argv[i], (u_char *) argv[i], len); + (void) ngx_cpystrn((u_char *) ngx_argv[i], (u_char *) argv[i], len); } ngx_argv[i] = NULL; @@ -473,8 +473,8 @@ ngx_core_module_create_conf(ngx_cycle_t *cycle) ccf->master = NGX_CONF_UNSET; ccf->worker_processes = NGX_CONF_UNSET; ccf->debug_points = NGX_CONF_UNSET; - ccf->user = (ngx_uid_t) NGX_CONF_UNSET; - ccf->group = (ngx_gid_t) NGX_CONF_UNSET; + ccf->user = (ngx_uid_t) NGX_CONF_UNSET_UINT; + ccf->group = (ngx_gid_t) NGX_CONF_UNSET_UINT; #if (NGX_THREADS) ccf->worker_threads = NGX_CONF_UNSET; ccf->thread_stack_size = NGX_CONF_UNSET_SIZE; @@ -507,7 +507,7 @@ ngx_core_module_init_conf(ngx_cycle_t *cycle, void *conf) #if !(NGX_WIN32) - if (ccf->user == (uid_t) NGX_CONF_UNSET && geteuid() == 0) { + if (ccf->user == (uid_t) NGX_CONF_UNSET_UINT && geteuid() == 0) { pwd = getpwnam(NGX_USER); if (pwd == NULL) { @@ -573,7 +573,7 @@ ngx_set_user(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) struct group *grp; ngx_str_t *value; - if (ccf->user != (uid_t) NGX_CONF_UNSET) { + if (ccf->user != (uid_t) NGX_CONF_UNSET_UINT) { return "is duplicate"; } diff --git a/src/core/nginx.h b/src/core/nginx.h index d1a5693b6..efc35b85e 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.32" +#define NGINX_VER "nginx/0.1.33" #define NGINX_VAR "NGINX" #define NGX_NEWPID_EXT ".newbin" diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index 42143bd2c..1a66ea92a 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -457,7 +457,7 @@ ngx_conf_read_token(ngx_conf_t *cf) return NGX_OK; case '}': - if (cf->args->nelts > 0) { + if (cf->args->nelts != 0) { ngx_log_error(NGX_LOG_EMERG, cf->log, 0, "unexpected \"}\" in %s:%ui", cf->conf_file->file.name.data, diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h index 675d427d4..4045e7a82 100644 --- a/src/core/ngx_config.h +++ b/src/core/ngx_config.h @@ -126,9 +126,9 @@ typedef long ngx_flag_t; #if ((__GNU__ == 2) && (__GNUC_MINOR__ < 8)) -#define NGX_MAX_UINT32_VALUE 0xffffffffLL +#define NGX_MAX_UINT32_VALUE (uint32_t) 0xffffffffLL #else -#define NGX_MAX_UINT32_VALUE 0xffffffff +#define NGX_MAX_UINT32_VALUE (uint32_t) 0xffffffff #endif diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h index eed955a72..bbca32ba6 100644 --- a/src/core/ngx_connection.h +++ b/src/core/ngx_connection.h @@ -17,8 +17,8 @@ typedef struct { struct sockaddr *sockaddr; socklen_t socklen; /* size of sockaddr */ - int addr; /* offset to address in sockaddr */ - int addr_text_max_len; + size_t addr; /* offset to address in sockaddr */ + size_t addr_text_max_len; ngx_str_t addr_text; int family; diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index eaebdb0bf..3a1c00e65 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -717,7 +717,7 @@ void ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user) continue; } #else - if (user != (ngx_uid_t) -1) { + if (user != (ngx_uid_t) NGX_CONF_UNSET_UINT) { if (ngx_file_info((const char *) file[i].name.data, &fi) == -1) { ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, diff --git a/src/core/ngx_file.c b/src/core/ngx_file.c index 46d2e0acb..efabd39b8 100644 --- a/src/core/ngx_file.c +++ b/src/core/ngx_file.c @@ -61,8 +61,8 @@ ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, ngx_pool_t *pool, n = ngx_next_temp_number(0); for ( ;; ) { - ngx_sprintf(file->name.data + path->name.len + 1 + path->len, - "%0muA%Z", n); + (void) ngx_sprintf(file->name.data + path->name.len + 1 + path->len, + "%0muA%Z", n); ngx_create_hashed_filename(file, path); @@ -123,7 +123,8 @@ ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, ngx_pool_t *pool, void ngx_create_hashed_filename(ngx_file_t *file, ngx_path_t *path) { - ngx_uint_t i, name, pos, level; + size_t name, pos, level; + ngx_uint_t i; name = file->name.len; pos = path->name.len + 1; @@ -151,8 +152,9 @@ ngx_create_hashed_filename(ngx_file_t *file, ngx_path_t *path) ngx_int_t ngx_create_path(ngx_file_t *file, ngx_path_t *path) { - int i, pos; - ngx_err_t err; + size_t pos; + ngx_err_t err; + ngx_uint_t i; pos = path->name.len; @@ -344,7 +346,7 @@ ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user) } } - if (user == (ngx_uid_t) -1) { + if (user == (ngx_uid_t) NGX_CONF_UNSET_UINT) { continue; } diff --git a/src/core/ngx_file.h b/src/core/ngx_file.h index 2bda85886..1efee294e 100644 --- a/src/core/ngx_file.h +++ b/src/core/ngx_file.h @@ -33,8 +33,8 @@ struct ngx_file_s { struct ngx_path_s { ngx_str_t name; - ngx_uint_t len; - ngx_uint_t level[3]; + size_t len; + size_t level[3]; ngx_gc_handler_pt cleaner; u_char *conf_file; diff --git a/src/core/ngx_garbage_collector.c b/src/core/ngx_garbage_collector.c index 07a3f7fc5..4eeaeb9be 100644 --- a/src/core/ngx_garbage_collector.c +++ b/src/core/ngx_garbage_collector.c @@ -6,7 +6,6 @@ #include <ngx_config.h> #include <ngx_core.h> -#include <ngx_garbage_collector.h> diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c index e7bdc410d..7b2d8d6b8 100644 --- a/src/core/ngx_inet.c +++ b/src/core/ngx_inet.c @@ -225,8 +225,9 @@ ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u) { char *err; u_char *host; + size_t len; in_addr_t in_addr; - ngx_uint_t i, len; + ngx_uint_t i; ngx_peers_t *peers; struct hostent *h; struct sockaddr_in *sin; @@ -281,7 +282,7 @@ ngx_inet_upstream_parse(ngx_conf_t *cf, ngx_inet_upstream_t *u) return NULL; } - ngx_cpystrn(host, u->host.data, u->host.len + 1); + (void) ngx_cpystrn(host, u->host.data, u->host.len + 1); /* AF_INET only */ diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c index 278258262..efc62f93c 100644 --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -179,7 +179,7 @@ ngx_log_write(ngx_log_t *log, u_char *errstr, size_t len) errstr[len++] = LF; - write(log->file->fd, errstr, len); + (void) write(log->file->fd, errstr, len); #endif } diff --git a/src/core/ngx_output_chain.c b/src/core/ngx_output_chain.c index e4a8723b2..1e7229114 100644 --- a/src/core/ngx_output_chain.c +++ b/src/core/ngx_output_chain.c @@ -381,12 +381,12 @@ ngx_output_chain_copy_buf(ngx_buf_t *dst, ngx_buf_t *src, ngx_uint_t sendfile) n = ngx_read_file(src->file, dst->pos, (size_t) size, src->file_pos); if (n == NGX_ERROR) { - return n; + return (ngx_int_t) n; } #if (NGX_FILE_AIO_READ) if (n == NGX_AGAIN) { - return n; + return (ngx_int_t) n; } #endif diff --git a/src/core/ngx_string.c b/src/core/ngx_string.c index 8d69c1b72..0307bb1cd 100644 --- a/src/core/ngx_string.c +++ b/src/core/ngx_string.c @@ -15,7 +15,7 @@ ngx_cpystrn(u_char *dst, u_char *src, size_t n) return dst; } - for (/* void */; --n; dst++, src++) { + for ( /* void */ ; --n; dst++, src++) { *dst = *src; if (*dst == '\0') { diff --git a/src/core/ngx_times.c b/src/core/ngx_times.c index 30938a174..f43987e85 100644 --- a/src/core/ngx_times.c +++ b/src/core/ngx_times.c @@ -155,14 +155,14 @@ ngx_time_update(time_t s) p = cached_http_time[slot]; - ngx_sprintf(p, "%s, %02d %s %4d %02d:%02d:%02d GMT", - week[ngx_cached_gmtime.ngx_tm_wday], - ngx_cached_gmtime.ngx_tm_mday, - months[ngx_cached_gmtime.ngx_tm_mon - 1], - ngx_cached_gmtime.ngx_tm_year, - ngx_cached_gmtime.ngx_tm_hour, - ngx_cached_gmtime.ngx_tm_min, - ngx_cached_gmtime.ngx_tm_sec); + (void) ngx_sprintf(p, "%s, %02d %s %4d %02d:%02d:%02d GMT", + week[ngx_cached_gmtime.ngx_tm_wday], + ngx_cached_gmtime.ngx_tm_mday, + months[ngx_cached_gmtime.ngx_tm_mon - 1], + ngx_cached_gmtime.ngx_tm_year, + ngx_cached_gmtime.ngx_tm_hour, + ngx_cached_gmtime.ngx_tm_min, + ngx_cached_gmtime.ngx_tm_sec); ngx_cached_http_time.data = p; @@ -175,7 +175,7 @@ ngx_time_update(time_t s) #elif (NGX_HAVE_GMTOFF) ngx_localtime(&tm); - ngx_gmtoff = tm.ngx_tm_gmtoff / 60; + ngx_gmtoff = (ngx_int_t) (tm.ngx_tm_gmtoff / 60); #else @@ -187,22 +187,22 @@ ngx_time_update(time_t s) p = cached_err_log_time[slot]; - ngx_sprintf(p, "%4d/%02d/%02d %02d:%02d:%02d", - tm.ngx_tm_year, tm.ngx_tm_mon, - tm.ngx_tm_mday, tm.ngx_tm_hour, - tm.ngx_tm_min, tm.ngx_tm_sec); + (void) ngx_sprintf(p, "%4d/%02d/%02d %02d:%02d:%02d", + tm.ngx_tm_year, tm.ngx_tm_mon, + tm.ngx_tm_mday, tm.ngx_tm_hour, + tm.ngx_tm_min, tm.ngx_tm_sec); ngx_cached_err_log_time.data = p; p = cached_http_log_time[slot]; - ngx_sprintf(p, "%02d/%s/%d:%02d:%02d:%02d %c%02d%02d", - tm.ngx_tm_mday, months[tm.ngx_tm_mon - 1], - tm.ngx_tm_year, tm.ngx_tm_hour, - tm.ngx_tm_min, tm.ngx_tm_sec, - ngx_gmtoff < 0 ? '-' : '+', - abs(ngx_gmtoff / 60), abs(ngx_gmtoff % 60)); + (void) ngx_sprintf(p, "%02d/%s/%d:%02d:%02d:%02d %c%02d%02d", + tm.ngx_tm_mday, months[tm.ngx_tm_mon - 1], + tm.ngx_tm_year, tm.ngx_tm_hour, + tm.ngx_tm_min, tm.ngx_tm_sec, + ngx_gmtoff < 0 ? '-' : '+', + abs(ngx_gmtoff / 60), abs(ngx_gmtoff % 60)); ngx_cached_http_log_time.data = p; diff --git a/src/core/ngx_unix_domain.c b/src/core/ngx_unix_domain.c index a7fdd6357..097d111c4 100644 --- a/src/core/ngx_unix_domain.c +++ b/src/core/ngx_unix_domain.c @@ -72,7 +72,7 @@ ngx_unix_upstream_parse(ngx_conf_t *cf, ngx_unix_domain_upstream_t *u) peers->number = 1; sun->sun_family = AF_UNIX; - ngx_cpystrn((u_char *) sun->sun_path, u->url.data + 5, len + 1); + (void) ngx_cpystrn((u_char *) sun->sun_path, u->url.data + 5, len + 1); peers->peer[0].sockaddr = (struct sockaddr *) sun; peers->peer[0].socklen = sizeof(struct sockaddr_un); diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c index a24be2444..92dd6cc9c 100644 --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -311,8 +311,8 @@ static char ngx_http_proxy_version[] = " HTTP/1.0" CRLF; static ngx_table_elt_t ngx_http_proxy_headers[] = { - { 0, ngx_string("Host"), ngx_string("$proxy_host"), }, - { 0, ngx_string("Connection"), ngx_string("close"), }, + { 0, ngx_string("Host"), ngx_string("$proxy_host") }, + { 0, ngx_string("Connection"), ngx_string("close") }, { 0, ngx_null_string, ngx_null_string } }; @@ -1560,6 +1560,8 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) *s = *h; + src = conf->headers_source->elts; + next: continue; diff --git a/src/http/modules/ngx_http_rewrite_module.c b/src/http/modules/ngx_http_rewrite_module.c index 47ff8c536..da4719b7b 100644 --- a/src/http/modules/ngx_http_rewrite_module.c +++ b/src/http/modules/ngx_http_rewrite_module.c @@ -556,8 +556,7 @@ ngx_http_rewrite(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) regex_end->redirect = regex->redirect; if (last) { - code = ngx_http_script_add_code(lcf->codes, sizeof(uintptr_t), - ®ex); + code = ngx_http_script_add_code(lcf->codes, sizeof(uintptr_t), ®ex); if (code == NULL) { return NGX_CONF_ERROR; } @@ -713,6 +712,11 @@ ngx_http_rewrite_if(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) } + if (lcf->captures < nlcf->captures) { + lcf->captures = nlcf->captures; + } + + if (elts != lcf->codes->elts) { if_code = (ngx_http_script_if_code_t *) ((u_char *) if_code + ((u_char *) lcf->codes->elts - elts)); diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c index f3defa07a..a45f2e570 100644 --- a/src/http/ngx_http_header_filter_module.c +++ b/src/http/ngx_http_header_filter_module.c @@ -264,11 +264,26 @@ ngx_http_header_filter(ngx_http_request_t *r) { r->headers_out.location->hash = 0; - len += sizeof("Location: http://") - 1 - + r->server_name.len + r->headers_out.location->value.len + 2; +#if (NGX_HTTP_SSL) + if (r->connection->ssl) { + len += sizeof("Location: https://") - 1 + + r->server_name.len + + r->headers_out.location->value.len + 2; + + if (r->port != 443) { + len += r->port_text->len; + } + + } else +#endif + { + len += sizeof("Location: http://") - 1 + + r->server_name.len + + r->headers_out.location->value.len + 2; - if (r->port != 80) { - len += r->port_text->len; + if (r->port != 80) { + len += r->port_text->len; + } } } @@ -396,13 +411,33 @@ ngx_http_header_filter(ngx_http_request_t *r) && r->headers_out.location->value.data[0] == '/') { p = b->last + sizeof("Location: ") - 1; - b->last = ngx_cpymem(b->last, "Location: http://", - sizeof("Location: http://") - 1); + + b->last = ngx_cpymem(b->last, "Location: http", + sizeof("Location: http") - 1); + +#if (NGX_HTTP_SSL) + if (r->connection->ssl) { + *b->last++ ='s'; + } +#endif + + *b->last++ = ':'; *b->last++ = '/'; *b->last++ = '/'; b->last = ngx_cpymem(b->last, r->server_name.data, r->server_name.len); - if (r->port != 80) { - b->last = ngx_cpymem(b->last, r->port_text->data, - r->port_text->len); + +#if (NGX_HTTP_SSL) + if (r->connection->ssl) { + if (r->port != 443) { + b->last = ngx_cpymem(b->last, r->port_text->data, + r->port_text->len); + } + } else +#endif + { + if (r->port != 80) { + b->last = ngx_cpymem(b->last, r->port_text->data, + r->port_text->len); + } } b->last = ngx_cpymem(b->last, r->headers_out.location->value.data, diff --git a/src/http/ngx_http_script.c b/src/http/ngx_http_script.c index ea1e56b34..89256b355 100644 --- a/src/http/ngx_http_script.c +++ b/src/http/ngx_http_script.c @@ -463,6 +463,9 @@ ngx_http_script_start_args_code(ngx_http_script_engine_t *e) } + +#if (NGX_PCRE) + void ngx_http_script_regex_start_code(ngx_http_script_engine_t *e) { @@ -693,6 +696,8 @@ ngx_http_script_regex_end_code(ngx_http_script_engine_t *e) e->ip += sizeof(ngx_http_script_regex_end_code_t); } +#endif + void ngx_http_script_return_code(ngx_http_script_engine_t *e) diff --git a/src/http/ngx_http_script.h b/src/http/ngx_http_script.h index cf80f22b4..eb6f17ea9 100644 --- a/src/http/ngx_http_script.h +++ b/src/http/ngx_http_script.h @@ -79,6 +79,8 @@ typedef struct { } ngx_http_script_copy_capture_code_t; +#if (NGX_PCRE) + typedef struct { ngx_http_script_code_pt code; ngx_regex_t *regex; @@ -114,6 +116,8 @@ typedef struct { uintptr_t redirect:1; } ngx_http_script_regex_end_code_t; +#endif + typedef struct { ngx_http_script_code_pt code; @@ -156,10 +160,11 @@ size_t ngx_http_script_copy_var_len_code(ngx_http_script_engine_t *e); void ngx_http_script_copy_var_code(ngx_http_script_engine_t *e); size_t ngx_http_script_copy_capture_len_code(ngx_http_script_engine_t *e); void ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e); +void ngx_http_script_start_args_code(ngx_http_script_engine_t *e); +#if (NGX_PCRE) void ngx_http_script_regex_start_code(ngx_http_script_engine_t *e); void ngx_http_script_regex_end_code(ngx_http_script_engine_t *e); -void ngx_http_script_copy_capture_code(ngx_http_script_engine_t *e); -void ngx_http_script_start_args_code(ngx_http_script_engine_t *e); +#endif void ngx_http_script_return_code(ngx_http_script_engine_t *e); void ngx_http_script_if_code(ngx_http_script_engine_t *e); void ngx_http_script_complex_value_code(ngx_http_script_engine_t *e); diff --git a/src/os/unix/ngx_errno.h b/src/os/unix/ngx_errno.h index 51d608bf4..310a1dc22 100644 --- a/src/os/unix/ngx_errno.h +++ b/src/os/unix/ngx_errno.h @@ -52,7 +52,7 @@ u_char *ngx_strerror_r(int err, u_char *errstr, size_t size); #else -/* Solaris has thread-safe strerror() */ +/* Solaris and Tru64 UNIX have thread-safe strerror() */ #define ngx_strerror_r(err, errstr, size) \ ngx_cpystrn(errstr, (u_char *) strerror(err), size) diff --git a/src/os/unix/ngx_time.c b/src/os/unix/ngx_time.c index 72137f952..1b1a56697 100644 --- a/src/os/unix/ngx_time.c +++ b/src/os/unix/ngx_time.c @@ -14,7 +14,7 @@ void ngx_localtime(ngx_tm_t *tm) time_t now; now = ngx_time(); - localtime_r(&now, tm); + (void) localtime_r(&now, tm); #else time_t now; @@ -37,7 +37,7 @@ void ngx_libc_localtime(struct tm *tm) time_t now; now = ngx_time(); - localtime_r(&now, tm); + (void) localtime_r(&now, tm); #else time_t now; @@ -57,7 +57,7 @@ void ngx_libc_gmtime(struct tm *tm) time_t now; now = ngx_time(); - gmtime_r(&now, tm); + (void) gmtime_r(&now, tm); #else time_t now; diff --git a/src/os/unix/ngx_time.h b/src/os/unix/ngx_time.h index 6e5a38ae2..d3d176fda 100644 --- a/src/os/unix/ngx_time.h +++ b/src/os/unix/ngx_time.h @@ -57,9 +57,9 @@ void ngx_localtime(ngx_tm_t *tm); void ngx_libc_localtime(struct tm *tm); void ngx_libc_gmtime(struct tm *tm); -#define ngx_gettimeofday(tp) gettimeofday(tp, NULL); -#define ngx_msleep(ms) usleep(ms * 1000) -#define ngx_sleep(s) sleep(s) +#define ngx_gettimeofday(tp) (void) gettimeofday(tp, NULL); +#define ngx_msleep(ms) (void) usleep(ms * 1000) +#define ngx_sleep(s) (void) sleep(s) #endif /* _NGX_TIME_H_INCLUDED_ */ |