Skip to content

Commit b998d16

Browse files
authored
Merge pull request #248 from chobits/for_pull_request
fixed segfault on windows for nginx-1.17.x ~ nginx-1.23.2
2 parents ce97814 + 0c65503 commit b998d16

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

patch/proxy_connect_rewrite_1018.patch

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
2-
index 3671558..1d3ae77 100644
2+
index 6664fa6..0b2d433 100644
33
--- a/src/http/ngx_http_core_module.c
44
+++ b/src/http/ngx_http_core_module.c
5-
@@ -950,6 +950,14 @@ ngx_http_core_find_config_phase(ngx_http_request_t *r,
5+
@@ -957,6 +957,14 @@ ngx_http_core_find_config_phase(ngx_http_request_t *r,
66
r->content_handler = NULL;
77
r->uri_changed = 0;
88

@@ -18,7 +18,7 @@ index 3671558..1d3ae77 100644
1818

1919
if (rc == NGX_ERROR) {
2020
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
21-
index cfc42f9..02a4877 100644
21+
index 20ad89a..c2c3c31 100644
2222
--- a/src/http/ngx_http_parse.c
2323
+++ b/src/http/ngx_http_parse.c
2424
@@ -107,6 +107,14 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
@@ -177,11 +177,11 @@ index cfc42f9..02a4877 100644
177177
case sw_spaces_before_uri:
178178

179179
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
180-
index eb53996..a7a5263 100644
180+
index 136c461..d7adadd 100644
181181
--- a/src/http/ngx_http_request.c
182182
+++ b/src/http/ngx_http_request.c
183-
@@ -1092,6 +1092,53 @@ ngx_http_process_request_line(ngx_event_t *rev)
184-
break;
183+
@@ -1112,6 +1112,55 @@ ngx_http_process_request_line(ngx_event_t *rev)
184+
r->http_protocol.len = r->request_end - r->http_protocol.data;
185185
}
186186

187187
+#if (NGX_HTTP_PROXY_CONNECT)
@@ -228,13 +228,15 @@ index eb53996..a7a5263 100644
228228
+ }
229229
+
230230
+ r->connect_port_n = port;
231-
+ }
231+
+
232+
+ /* skip processing uri */
233+
+ } else
232234
+#endif
233235
+
234-
if (r->schema_end) {
235-
r->schema.len = r->schema_end - r->schema_start;
236-
r->schema.data = r->schema_start;
237-
@@ -1671,6 +1718,19 @@ ngx_http_alloc_large_header_buffer(ngx_http_request_t *r,
236+
if (ngx_http_process_request_uri(r) != NGX_OK) {
237+
break;
238+
}
239+
@@ -1705,6 +1754,19 @@ ngx_http_alloc_large_header_buffer(ngx_http_request_t *r,
238240
r->schema_end = new + (r->schema_end - old);
239241
}
240242

@@ -255,7 +257,7 @@ index eb53996..a7a5263 100644
255257
r->host_start = new + (r->host_start - old);
256258
if (r->host_end) {
257259
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
258-
index 70c2d42..90f0934 100644
260+
index 6dfb4a4..7b5cbdb 100644
259261
--- a/src/http/ngx_http_request.h
260262
+++ b/src/http/ngx_http_request.h
261263
@@ -42,6 +42,10 @@
@@ -286,10 +288,10 @@ index 70c2d42..90f0934 100644
286288
ngx_str_t http_protocol;
287289
ngx_str_t schema;
288290
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
289-
index e067cf0..4bb9260 100644
291+
index 942dacd..6c59d6a 100644
290292
--- a/src/http/ngx_http_variables.c
291293
+++ b/src/http/ngx_http_variables.c
292-
@@ -161,6 +161,14 @@ static ngx_int_t ngx_http_variable_time_local(ngx_http_request_t *r,
294+
@@ -163,6 +163,14 @@ static ngx_int_t ngx_http_variable_time_local(ngx_http_request_t *r,
293295

294296
static ngx_http_variable_t ngx_http_core_variables[] = {
295297

patch/proxy_connect_rewrite_102101.patch

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
2-
index bad43ea5..b2cebb38 100644
2+
index c7463dc..41a0a7a 100644
33
--- a/src/http/ngx_http_core_module.c
44
+++ b/src/http/ngx_http_core_module.c
55
@@ -957,6 +957,14 @@ ngx_http_core_find_config_phase(ngx_http_request_t *r,
@@ -18,7 +18,7 @@ index bad43ea5..b2cebb38 100644
1818

1919
if (rc == NGX_ERROR) {
2020
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
21-
index 6460da29..7b209fa8 100644
21+
index 6460da2..7b209fa 100644
2222
--- a/src/http/ngx_http_parse.c
2323
+++ b/src/http/ngx_http_parse.c
2424
@@ -107,6 +107,14 @@ ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
@@ -163,11 +163,11 @@ index 6460da29..7b209fa8 100644
163163
case sw_spaces_before_uri:
164164

165165
diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c
166-
index 2d1845d0..ca1e5c0a 100644
166+
index 013b715..f4fa0a4 100644
167167
--- a/src/http/ngx_http_request.c
168168
+++ b/src/http/ngx_http_request.c
169-
@@ -1118,6 +1118,53 @@ ngx_http_process_request_line(ngx_event_t *rev)
170-
break;
169+
@@ -1102,6 +1102,55 @@ ngx_http_process_request_line(ngx_event_t *rev)
170+
r->http_protocol.len = r->request_end - r->http_protocol.data;
171171
}
172172

173173
+#if (NGX_HTTP_PROXY_CONNECT)
@@ -214,13 +214,15 @@ index 2d1845d0..ca1e5c0a 100644
214214
+ }
215215
+
216216
+ r->connect_port_n = port;
217-
+ }
217+
+
218+
+ /* skip processing request uri */
219+
+ } else
218220
+#endif
219221
+
220-
if (r->schema_end) {
221-
r->schema.len = r->schema_end - r->schema_start;
222-
r->schema.data = r->schema_start;
223-
@@ -1709,6 +1756,19 @@ ngx_http_alloc_large_header_buffer(ngx_http_request_t *r,
222+
if (ngx_http_process_request_uri(r) != NGX_OK) {
223+
break;
224+
}
225+
@@ -1697,6 +1746,19 @@ ngx_http_alloc_large_header_buffer(ngx_http_request_t *r,
224226
r->schema_end = new + (r->schema_end - old);
225227
}
226228

@@ -240,7 +242,7 @@ index 2d1845d0..ca1e5c0a 100644
240242
if (r->host_start) {
241243
r->host_start = new + (r->host_start - old);
242244
if (r->host_end) {
243-
@@ -2015,13 +2075,6 @@ ngx_http_process_request_header(ngx_http_request_t *r)
245+
@@ -2011,13 +2073,6 @@ ngx_http_process_request_header(ngx_http_request_t *r)
244246
}
245247
}
246248

@@ -255,10 +257,10 @@ index 2d1845d0..ca1e5c0a 100644
255257
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
256258
"client sent TRACE method");
257259
diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h
258-
index 63576274..cac53b68 100644
260+
index b1269d2..a68bd03 100644
259261
--- a/src/http/ngx_http_request.h
260262
+++ b/src/http/ngx_http_request.h
261-
@@ -411,6 +411,15 @@ struct ngx_http_request_s {
263+
@@ -414,6 +414,15 @@ struct ngx_http_request_s {
262264
ngx_str_t exten;
263265
ngx_str_t unparsed_uri;
264266

@@ -275,7 +277,7 @@ index 63576274..cac53b68 100644
275277
ngx_str_t http_protocol;
276278
ngx_str_t schema;
277279
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
278-
index c25d80cc..8bb40d70 100644
280+
index 942dacd..6c59d6a 100644
279281
--- a/src/http/ngx_http_variables.c
280282
+++ b/src/http/ngx_http_variables.c
281283
@@ -163,6 +163,14 @@ static ngx_int_t ngx_http_variable_time_local(ngx_http_request_t *r,

0 commit comments

Comments
 (0)