|
| 1 | +--- src/http/modules/ngx_http_fastcgi_module.c |
| 2 | ++++ src/http/modules/ngx_http_fastcgi_module.c |
| 3 | +@@ -1501,10 +1501,10 @@ ngx_http_fastcgi_process_header(ngx_http |
| 4 | + h->lowcase_key = h->key.data + h->key.len + 1 |
| 5 | + + h->value.len + 1; |
| 6 | + |
| 7 | +- ngx_cpystrn(h->key.data, r->header_name_start, |
| 8 | +- h->key.len + 1); |
| 9 | +- ngx_cpystrn(h->value.data, r->header_start, |
| 10 | +- h->value.len + 1); |
| 11 | ++ ngx_memcpy(h->key.data, r->header_name_start, h->key.len); |
| 12 | ++ h->key.data[h->key.len] = '\0'; |
| 13 | ++ ngx_memcpy(h->value.data, r->header_start, h->value.len); |
| 14 | ++ h->value.data[h->value.len] = '\0'; |
| 15 | + } |
| 16 | + |
| 17 | + h->hash = r->header_hash; |
| 18 | +--- src/http/modules/ngx_http_proxy_module.c |
| 19 | ++++ src/http/modules/ngx_http_proxy_module.c |
| 20 | +@@ -1381,8 +1381,10 @@ ngx_http_proxy_process_header(ngx_http_r |
| 21 | + h->value.data = h->key.data + h->key.len + 1; |
| 22 | + h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1; |
| 23 | + |
| 24 | +- ngx_cpystrn(h->key.data, r->header_name_start, h->key.len + 1); |
| 25 | +- ngx_cpystrn(h->value.data, r->header_start, h->value.len + 1); |
| 26 | ++ ngx_memcpy(h->key.data, r->header_name_start, h->key.len); |
| 27 | ++ h->key.data[h->key.len] = '\0'; |
| 28 | ++ ngx_memcpy(h->value.data, r->header_start, h->value.len); |
| 29 | ++ h->value.data[h->value.len] = '\0'; |
| 30 | + |
| 31 | + if (h->key.len == r->lowcase_index) { |
| 32 | + ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); |
| 33 | +--- src/http/modules/ngx_http_scgi_module.c |
| 34 | ++++ src/http/modules/ngx_http_scgi_module.c |
| 35 | +@@ -941,8 +941,10 @@ ngx_http_scgi_process_header(ngx_http_re |
| 36 | + h->value.data = h->key.data + h->key.len + 1; |
| 37 | + h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1; |
| 38 | + |
| 39 | +- ngx_cpystrn(h->key.data, r->header_name_start, h->key.len + 1); |
| 40 | +- ngx_cpystrn(h->value.data, r->header_start, h->value.len + 1); |
| 41 | ++ ngx_memcpy(h->key.data, r->header_name_start, h->key.len); |
| 42 | ++ h->key.data[h->key.len] = '\0'; |
| 43 | ++ ngx_memcpy(h->value.data, r->header_start, h->value.len); |
| 44 | ++ h->value.data[h->value.len] = '\0'; |
| 45 | + |
| 46 | + if (h->key.len == r->lowcase_index) { |
| 47 | + ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); |
| 48 | +--- src/http/modules/ngx_http_uwsgi_module.c |
| 49 | ++++ src/http/modules/ngx_http_uwsgi_module.c |
| 50 | +@@ -985,8 +985,10 @@ ngx_http_uwsgi_process_header(ngx_http_r |
| 51 | + h->value.data = h->key.data + h->key.len + 1; |
| 52 | + h->lowcase_key = h->key.data + h->key.len + 1 + h->value.len + 1; |
| 53 | + |
| 54 | +- ngx_cpystrn(h->key.data, r->header_name_start, h->key.len + 1); |
| 55 | +- ngx_cpystrn(h->value.data, r->header_start, h->value.len + 1); |
| 56 | ++ ngx_memcpy(h->key.data, r->header_name_start, h->key.len); |
| 57 | ++ h->key.data[h->key.len] = '\0'; |
| 58 | ++ ngx_memcpy(h->value.data, r->header_start, h->value.len); |
| 59 | ++ h->value.data[h->value.len] = '\0'; |
| 60 | + |
| 61 | + if (h->key.len == r->lowcase_index) { |
| 62 | + ngx_memcpy(h->lowcase_key, r->lowcase_header, h->key.len); |
| 63 | +--- src/http/ngx_http_parse.c |
| 64 | ++++ src/http/ngx_http_parse.c |
| 65 | +@@ -874,6 +874,10 @@ ngx_http_parse_header_line(ngx_http_requ |
| 66 | + break; |
| 67 | + } |
| 68 | + |
| 69 | ++ if (ch == '\0') { |
| 70 | ++ return NGX_HTTP_PARSE_INVALID_HEADER; |
| 71 | ++ } |
| 72 | ++ |
| 73 | + r->invalid_header = 1; |
| 74 | + |
| 75 | + break; |
| 76 | +@@ -936,6 +940,10 @@ ngx_http_parse_header_line(ngx_http_requ |
| 77 | + break; |
| 78 | + } |
| 79 | + |
| 80 | ++ if (ch == '\0') { |
| 81 | ++ return NGX_HTTP_PARSE_INVALID_HEADER; |
| 82 | ++ } |
| 83 | ++ |
| 84 | + r->invalid_header = 1; |
| 85 | + |
| 86 | + break; |
| 87 | +@@ -954,6 +962,8 @@ ngx_http_parse_header_line(ngx_http_requ |
| 88 | + r->header_start = p; |
| 89 | + r->header_end = p; |
| 90 | + goto done; |
| 91 | ++ case '\0': |
| 92 | ++ return NGX_HTTP_PARSE_INVALID_HEADER; |
| 93 | + default: |
| 94 | + r->header_start = p; |
| 95 | + state = sw_value; |
| 96 | +@@ -975,6 +985,8 @@ ngx_http_parse_header_line(ngx_http_requ |
| 97 | + case LF: |
| 98 | + r->header_end = p; |
| 99 | + goto done; |
| 100 | ++ case '\0': |
| 101 | ++ return NGX_HTTP_PARSE_INVALID_HEADER; |
| 102 | + } |
| 103 | + break; |
| 104 | + |
| 105 | +@@ -988,6 +1000,8 @@ ngx_http_parse_header_line(ngx_http_requ |
| 106 | + break; |
| 107 | + case LF: |
| 108 | + goto done; |
| 109 | ++ case '\0': |
| 110 | ++ return NGX_HTTP_PARSE_INVALID_HEADER; |
| 111 | + default: |
| 112 | + state = sw_value; |
| 113 | + break; |
0 commit comments