comparison src/http/modules/ngx_http_uwsgi_module.c @ 666:bf8b55a5ac89 NGINX_1_1_17

nginx 1.1.17 *) Security: content of previously freed memory might be sent to a client if backend returned specially crafted response. Thanks to Matthew Daley. *) Bugfix: in the embedded perl module if used from SSI. Thanks to Matthew Daley. *) Bugfix: in the ngx_http_uwsgi_module.
author Igor Sysoev <http://sysoev.ru>
date Thu, 15 Mar 2012 00:00:00 +0400
parents d0f7a625f27c
children f41d4b305d22
comparison
equal deleted inserted replaced
665:a8821023989f 666:bf8b55a5ac89
40 static ngx_int_t ngx_http_uwsgi_eval(ngx_http_request_t *r, 40 static ngx_int_t ngx_http_uwsgi_eval(ngx_http_request_t *r,
41 ngx_http_uwsgi_loc_conf_t *uwcf); 41 ngx_http_uwsgi_loc_conf_t *uwcf);
42 static ngx_int_t ngx_http_uwsgi_create_request(ngx_http_request_t *r); 42 static ngx_int_t ngx_http_uwsgi_create_request(ngx_http_request_t *r);
43 static ngx_int_t ngx_http_uwsgi_reinit_request(ngx_http_request_t *r); 43 static ngx_int_t ngx_http_uwsgi_reinit_request(ngx_http_request_t *r);
44 static ngx_int_t ngx_http_uwsgi_process_status_line(ngx_http_request_t *r); 44 static ngx_int_t ngx_http_uwsgi_process_status_line(ngx_http_request_t *r);
45 static ngx_int_t ngx_http_uwsgi_process_header(ngx_http_request_t *r);
46 static ngx_int_t ngx_http_uwsgi_process_header(ngx_http_request_t *r); 45 static ngx_int_t ngx_http_uwsgi_process_header(ngx_http_request_t *r);
47 static void ngx_http_uwsgi_abort_request(ngx_http_request_t *r); 46 static void ngx_http_uwsgi_abort_request(ngx_http_request_t *r);
48 static void ngx_http_uwsgi_finalize_request(ngx_http_request_t *r, 47 static void ngx_http_uwsgi_finalize_request(ngx_http_request_t *r,
49 ngx_int_t rc); 48 ngx_int_t rc);
50 49
910 if (rc == NGX_AGAIN) { 909 if (rc == NGX_AGAIN) {
911 return rc; 910 return rc;
912 } 911 }
913 912
914 if (rc == NGX_ERROR) { 913 if (rc == NGX_ERROR) {
915 r->http_version = NGX_HTTP_VERSION_9;
916
917 u->process_header = ngx_http_uwsgi_process_header; 914 u->process_header = ngx_http_uwsgi_process_header;
918
919 return ngx_http_uwsgi_process_header(r); 915 return ngx_http_uwsgi_process_header(r);
920 } 916 }
921 917
922 if (u->state) { 918 if (u->state) {
923 u->state->status = status->code; 919 u->state->status = status->code;
983 } 979 }
984 980
985 h->value.data = h->key.data + h->key.len + 1; 981 h->value.data = h->key.data + h->key.len + 1;
986 h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1; 982 h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1;
987 983
988 ngx_cpystrn(h->key.data, r->header_name_start, h->key.len + 1); 984 ngx_memcpy(h->key.data, r->header_name_start, h->key.len);
989 ngx_cpystrn(h->value.data, r->header_start, h->value.len + 1); 985 h->key.data[h->key.len] = '\0';
986 ngx_memcpy(h->value.data, r->header_start, h->value.len);
987 h->value.data[h->value.len] = '\0';
990 988
991 if (h->key.len == r->lowcase_index) { 989 if (h->key.len == r->lowcase_index) {
992 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); 990 ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len);
993 991
994 } else { 992 } else {
1013 /* a whole header has been parsed successfully */ 1011 /* a whole header has been parsed successfully */
1014 1012
1015 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1013 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1016 "http uwsgi header done"); 1014 "http uwsgi header done");
1017 1015
1018 if (r->http_version > NGX_HTTP_VERSION_9) { 1016 u = r->upstream;
1017
1018 if (u->headers_in.status_n) {
1019 return NGX_OK; 1019 return NGX_OK;
1020 } 1020 }
1021
1022 u = r->upstream;
1023 1021
1024 if (u->headers_in.status) { 1022 if (u->headers_in.status) {
1025 status_line = &u->headers_in.status->value; 1023 status_line = &u->headers_in.status->value;
1026 1024
1027 status = ngx_atoi(status_line->data, 3); 1025 status = ngx_atoi(status_line->data, 3);
1030 "upstream sent invalid status \"%V\"", 1028 "upstream sent invalid status \"%V\"",
1031 status_line); 1029 status_line);
1032 return NGX_HTTP_UPSTREAM_INVALID_HEADER; 1030 return NGX_HTTP_UPSTREAM_INVALID_HEADER;
1033 } 1031 }
1034 1032
1035 r->http_version = NGX_HTTP_VERSION_10;
1036 u->headers_in.status_n = status; 1033 u->headers_in.status_n = status;
1037 u->headers_in.status_line = *status_line; 1034 u->headers_in.status_line = *status_line;
1038 1035
1039 } else if (u->headers_in.location) { 1036 } else if (u->headers_in.location) {
1040 r->http_version = NGX_HTTP_VERSION_10;
1041 u->headers_in.status_n = 302; 1037 u->headers_in.status_n = 302;
1042 ngx_str_set(&u->headers_in.status_line, 1038 ngx_str_set(&u->headers_in.status_line,
1043 "302 Moved Temporarily"); 1039 "302 Moved Temporarily");
1044 1040
1045 } else { 1041 } else {
1046 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
1047 "upstream sent neither valid HTTP/1.0 header "
1048 "nor \"Status\" header line");
1049 u->headers_in.status_n = 200; 1042 u->headers_in.status_n = 200;
1050 ngx_str_set(&u->headers_in.status_line, "200 OK"); 1043 ngx_str_set(&u->headers_in.status_line, "200 OK");
1051 } 1044 }
1052 1045
1053 if (u->state) { 1046 if (u->state) {
1439 if (conf->params_source == NULL) { 1432 if (conf->params_source == NULL) {
1440 conf->params_source = prev->params_source; 1433 conf->params_source = prev->params_source;
1441 1434
1442 if (prev->headers_hash.buckets 1435 if (prev->headers_hash.buckets
1443 #if (NGX_HTTP_CACHE) 1436 #if (NGX_HTTP_CACHE)
1444 && ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL)) 1437 && ((conf->upstream.cache == NULL)
1438 == (prev->upstream.cache == NULL))
1445 #endif 1439 #endif
1446 ) 1440 )
1447 { 1441 {
1448 conf->flushes = prev->flushes; 1442 conf->flushes = prev->flushes;
1449 conf->params_len = prev->params_len; 1443 conf->params_len = prev->params_len;