diff options
author | Alexander M Pickering <alex@cogarr.net> | 2024-11-08 19:32:06 -0600 |
---|---|---|
committer | Alexander M Pickering <alex@cogarr.net> | 2024-11-08 19:32:06 -0600 |
commit | 2453144d35095bc743b0b0aac28888027d920d0d (patch) | |
tree | cd31f4fb56ad8bd9a2804a007d23b23f33c08562 | |
parent | 715149e2011bd89f30440c8e62d7cff8e5968ad4 (diff) | |
download | busybox-w32-packaging-2453144d35095bc743b0b0aac28888027d920d0d.tar.gz busybox-w32-packaging-2453144d35095bc743b0b0aac28888027d920d0d.tar.bz2 busybox-w32-packaging-2453144d35095bc743b0b0aac28888027d920d0d.zip |
Try creating a socket pair
-rw-r--r-- | libressl.patch | 59 |
1 files changed, 32 insertions, 27 deletions
diff --git a/libressl.patch b/libressl.patch index 24963ac..ee924e6 100644 --- a/libressl.patch +++ b/libressl.patch | |||
@@ -135,7 +135,7 @@ index 9f1dd67ec..7e8da6df2 100644 | |||
135 | static void tls_xwrite(tls_state_t *tls, int len) | 135 | static void tls_xwrite(tls_state_t *tls, int len) |
136 | { | 136 | { |
137 | diff --git a/networking/wget.c b/networking/wget.c | 137 | diff --git a/networking/wget.c b/networking/wget.c |
138 | index 6a64836fb..96ebc298b 100644 | 138 | index 6a64836fb..3f1213af1 100644 |
139 | --- a/networking/wget.c | 139 | --- a/networking/wget.c |
140 | +++ b/networking/wget.c | 140 | +++ b/networking/wget.c |
141 | @@ -169,7 +169,8 @@ | 141 | @@ -169,7 +169,8 @@ |
@@ -155,9 +155,10 @@ index 6a64836fb..96ebc298b 100644 | |||
155 | + printf("wget fgets_trim_sanitize 1\n"); | 155 | + printf("wget fgets_trim_sanitize 1\n"); |
156 | set_alarm(); | 156 | set_alarm(); |
157 | - if (fgets(G.wget_buf, sizeof(G.wget_buf), fp) == NULL) | 157 | - if (fgets(G.wget_buf, sizeof(G.wget_buf), fp) == NULL) |
158 | - bb_simple_perror_msg_and_die("error getting response"); | ||
158 | + printf("wget fgets_trim_sanitize 2\n"); | 159 | + printf("wget fgets_trim_sanitize 2\n"); |
159 | + if (fgets(G.wget_buf, sizeof(G.wget_buf), fp) == NULL){ | 160 | + if (fgets(G.wget_buf, sizeof(G.wget_buf), fp) == NULL){ |
160 | bb_simple_perror_msg_and_die("error getting response"); | 161 | + bb_simple_perror_msg_and_die("error getting response: %s",strerror(errno)); |
161 | + } | 162 | + } |
162 | clear_alarm(); | 163 | clear_alarm(); |
163 | 164 | ||
@@ -193,16 +194,21 @@ index 6a64836fb..96ebc298b 100644 | |||
193 | static int spawn_https_helper_openssl(const char *host, unsigned port) | 194 | static int spawn_https_helper_openssl(const char *host, unsigned port) |
194 | { | 195 | { |
195 | char *allocated = NULL; | 196 | char *allocated = NULL; |
196 | @@ -777,6 +788,33 @@ static int spawn_https_helper_openssl(const char *host, unsigned port) | 197 | @@ -777,6 +788,37 @@ static int spawn_https_helper_openssl(const char *host, unsigned port) |
197 | # endif | 198 | # endif |
198 | return sp[0]; | 199 | return sp[0]; |
199 | } | 200 | } |
200 | +# else | 201 | +# else |
201 | +#include <tls.h> | 202 | +#include <tls.h> |
203 | +#include <winsock2.h> | ||
202 | +static int spawn_https_helper_openssl(const char *host, unsigned port) | 204 | +static int spawn_https_helper_openssl(const char *host, unsigned port) |
203 | +{ | 205 | +{ |
204 | + char* allocated = NULL; | 206 | + char* allocated = NULL; |
205 | + char *servername, *cmd; | 207 | + char *servername, *cmd; |
208 | + int sp[2]; | ||
209 | + if (socketpair(AF_UNIX, SOCK_STREAM, 0, sp) != 0) | ||
210 | + bb_simple_perror_msg_and_die("socketpair"); | ||
211 | + | ||
206 | + if(!strchr(host,":")) | 212 | + if(!strchr(host,":")) |
207 | + host = allocated = xasprintf("%s:%u",host,port); | 213 | + host = allocated = xasprintf("%s:%u",host,port); |
208 | + servername = xstrdup(host); | 214 | + servername = xstrdup(host); |
@@ -216,18 +222,17 @@ index 6a64836fb..96ebc298b 100644 | |||
216 | + bb_error_msg_and_die("Out of memory 2"); | 222 | + bb_error_msg_and_die("Out of memory 2"); |
217 | + if(tls_configure(ctx,config) != 0) | 223 | + if(tls_configure(ctx,config) != 0) |
218 | + bb_error_msg_and_die("Failed to configure client"); | 224 | + bb_error_msg_and_die("Failed to configure client"); |
219 | + int ret = tls_connect(ctx,servername,NULL); | 225 | + tls_connect_fds(ctx, sp[0], sp[1], servername); |
220 | + tls_config_free(config); | 226 | + tls_config_free(config); |
221 | + tls_free(ctx); | ||
222 | + free(allocated); | 227 | + free(allocated); |
223 | + free(servername); | 228 | + free(servername); |
224 | + return ret; | 229 | + return sp[0]; |
225 | +} | 230 | +} |
226 | +# endif | 231 | +# endif |
227 | #endif | 232 | #endif |
228 | 233 | ||
229 | #if ENABLE_FEATURE_WGET_HTTPS | 234 | #if ENABLE_FEATURE_WGET_HTTPS |
230 | @@ -1151,6 +1189,7 @@ static void download_one_url(const char *url) | 235 | @@ -1151,6 +1193,7 @@ static void download_one_url(const char *url) |
231 | server.user = NULL; | 236 | server.user = NULL; |
232 | target.user = NULL; | 237 | target.user = NULL; |
233 | 238 | ||
@@ -235,7 +240,7 @@ index 6a64836fb..96ebc298b 100644 | |||
235 | parse_url(url, &target); | 240 | parse_url(url, &target); |
236 | 241 | ||
237 | /* Use the proxy if necessary */ | 242 | /* Use the proxy if necessary */ |
238 | @@ -1172,6 +1211,7 @@ static void download_one_url(const char *url) | 243 | @@ -1172,6 +1215,7 @@ static void download_one_url(const char *url) |
239 | server.host = target.host; | 244 | server.host = target.host; |
240 | } | 245 | } |
241 | } | 246 | } |
@@ -243,7 +248,7 @@ index 6a64836fb..96ebc298b 100644 | |||
243 | 248 | ||
244 | if (ENABLE_FEATURE_IPV6) | 249 | if (ENABLE_FEATURE_IPV6) |
245 | strip_ipv6_scope_id(target.host); | 250 | strip_ipv6_scope_id(target.host); |
246 | @@ -1191,6 +1231,7 @@ static void download_one_url(const char *url) | 251 | @@ -1191,6 +1235,7 @@ static void download_one_url(const char *url) |
247 | G.fname_out = fname_out_alloc = xstrdup(G.fname_out); | 252 | G.fname_out = fname_out_alloc = xstrdup(G.fname_out); |
248 | } | 253 | } |
249 | } | 254 | } |
@@ -251,7 +256,7 @@ index 6a64836fb..96ebc298b 100644 | |||
251 | #if ENABLE_FEATURE_WGET_STATUSBAR | 256 | #if ENABLE_FEATURE_WGET_STATUSBAR |
252 | G.curfile = bb_get_last_path_component_nostrip(G.fname_out); | 257 | G.curfile = bb_get_last_path_component_nostrip(G.fname_out); |
253 | #endif | 258 | #endif |
254 | @@ -1206,15 +1247,19 @@ static void download_one_url(const char *url) | 259 | @@ -1206,15 +1251,19 @@ static void download_one_url(const char *url) |
255 | * We are not sure it exists on remote side */ | 260 | * We are not sure it exists on remote side */ |
256 | } | 261 | } |
257 | 262 | ||
@@ -271,7 +276,7 @@ index 6a64836fb..96ebc298b 100644 | |||
271 | /*G.content_len = 0; - redundant, got_clen = 0 is enough */ | 276 | /*G.content_len = 0; - redundant, got_clen = 0 is enough */ |
272 | G.got_clen = 0; | 277 | G.got_clen = 0; |
273 | G.chunked = 0; | 278 | G.chunked = 0; |
274 | @@ -1229,37 +1274,49 @@ static void download_one_url(const char *url) | 279 | @@ -1229,37 +1278,49 @@ static void download_one_url(const char *url) |
275 | 280 | ||
276 | /* Open socket to http(s) server */ | 281 | /* Open socket to http(s) server */ |
277 | #if ENABLE_FEATURE_WGET_OPENSSL | 282 | #if ENABLE_FEATURE_WGET_OPENSSL |
@@ -323,7 +328,7 @@ index 6a64836fb..96ebc298b 100644 | |||
323 | /* Send HTTP request */ | 328 | /* Send HTTP request */ |
324 | if (use_proxy) { | 329 | if (use_proxy) { |
325 | SENDFMT(sfp, "GET %s://%s/%s HTTP/1.1\r\n", | 330 | SENDFMT(sfp, "GET %s://%s/%s HTTP/1.1\r\n", |
326 | @@ -1270,6 +1327,7 @@ static void download_one_url(const char *url) | 331 | @@ -1270,6 +1331,7 @@ static void download_one_url(const char *url) |
327 | (option_mask32 & WGET_OPT_POST) ? "POST" : "GET", | 332 | (option_mask32 & WGET_OPT_POST) ? "POST" : "GET", |
328 | target.path); | 333 | target.path); |
329 | } | 334 | } |
@@ -331,7 +336,7 @@ index 6a64836fb..96ebc298b 100644 | |||
331 | if (!USR_HEADER_HOST) | 336 | if (!USR_HEADER_HOST) |
332 | SENDFMT(sfp, "Host: %s\r\n", target.host); | 337 | SENDFMT(sfp, "Host: %s\r\n", target.host); |
333 | if (!USR_HEADER_USER_AGENT) | 338 | if (!USR_HEADER_USER_AGENT) |
334 | @@ -1280,6 +1338,7 @@ static void download_one_url(const char *url) | 339 | @@ -1280,6 +1342,7 @@ static void download_one_url(const char *url) |
335 | */ | 340 | */ |
336 | SENDFMT(sfp, "Connection: close\r\n"); | 341 | SENDFMT(sfp, "Connection: close\r\n"); |
337 | 342 | ||
@@ -339,7 +344,7 @@ index 6a64836fb..96ebc298b 100644 | |||
339 | #if ENABLE_FEATURE_WGET_AUTHENTICATION | 344 | #if ENABLE_FEATURE_WGET_AUTHENTICATION |
340 | if (target.user && !USR_HEADER_AUTH) { | 345 | if (target.user && !USR_HEADER_AUTH) { |
341 | SENDFMT(sfp, "Proxy-Authorization: Basic %s\r\n"+6, | 346 | SENDFMT(sfp, "Proxy-Authorization: Basic %s\r\n"+6, |
342 | @@ -1291,6 +1350,7 @@ static void download_one_url(const char *url) | 347 | @@ -1291,6 +1354,7 @@ static void download_one_url(const char *url) |
343 | } | 348 | } |
344 | #endif | 349 | #endif |
345 | 350 | ||
@@ -347,7 +352,7 @@ index 6a64836fb..96ebc298b 100644 | |||
347 | if (G.beg_range != 0 && !USR_HEADER_RANGE) | 352 | if (G.beg_range != 0 && !USR_HEADER_RANGE) |
348 | SENDFMT(sfp, "Range: bytes=%"OFF_FMT"u-\r\n", G.beg_range); | 353 | SENDFMT(sfp, "Range: bytes=%"OFF_FMT"u-\r\n", G.beg_range); |
349 | 354 | ||
350 | @@ -1300,6 +1360,7 @@ static void download_one_url(const char *url) | 355 | @@ -1300,6 +1364,7 @@ static void download_one_url(const char *url) |
351 | fputs(G.extra_headers, sfp); | 356 | fputs(G.extra_headers, sfp); |
352 | } | 357 | } |
353 | 358 | ||
@@ -355,7 +360,7 @@ index 6a64836fb..96ebc298b 100644 | |||
355 | if (option_mask32 & WGET_OPT_POST_FILE) { | 360 | if (option_mask32 & WGET_OPT_POST_FILE) { |
356 | int fd = xopen_stdin(G.post_file); | 361 | int fd = xopen_stdin(G.post_file); |
357 | G.post_data = xmalloc_read(fd, NULL); | 362 | G.post_data = xmalloc_read(fd, NULL); |
358 | @@ -1314,15 +1375,18 @@ static void download_one_url(const char *url) | 363 | @@ -1314,15 +1379,18 @@ static void download_one_url(const char *url) |
359 | ); | 364 | ); |
360 | } | 365 | } |
361 | # if ENABLE_PLATFORM_MINGW32 | 366 | # if ENABLE_PLATFORM_MINGW32 |
@@ -374,7 +379,7 @@ index 6a64836fb..96ebc298b 100644 | |||
374 | } else | 379 | } else |
375 | # else | 380 | # else |
376 | SENDFMT(sfp, | 381 | SENDFMT(sfp, |
377 | @@ -1338,6 +1402,7 @@ static void download_one_url(const char *url) | 382 | @@ -1338,6 +1406,7 @@ static void download_one_url(const char *url) |
378 | SENDFMT(sfp, "\r\n"); | 383 | SENDFMT(sfp, "\r\n"); |
379 | } | 384 | } |
380 | 385 | ||
@@ -382,7 +387,7 @@ index 6a64836fb..96ebc298b 100644 | |||
382 | fflush(sfp); | 387 | fflush(sfp); |
383 | 388 | ||
384 | /* Tried doing this unconditionally. | 389 | /* Tried doing this unconditionally. |
385 | @@ -1358,14 +1423,21 @@ static void download_one_url(const char *url) | 390 | @@ -1358,14 +1427,21 @@ static void download_one_url(const char *url) |
386 | * Retrieve HTTP response line and check for "200" status code. | 391 | * Retrieve HTTP response line and check for "200" status code. |
387 | */ | 392 | */ |
388 | read_response: | 393 | read_response: |
@@ -404,7 +409,7 @@ index 6a64836fb..96ebc298b 100644 | |||
404 | switch (status) { | 409 | switch (status) { |
405 | case 0: | 410 | case 0: |
406 | case 100: | 411 | case 100: |
407 | @@ -1441,6 +1513,7 @@ However, in real world it was observed that some web servers | 412 | @@ -1441,6 +1517,7 @@ However, in real world it was observed that some web servers |
408 | /* | 413 | /* |
409 | * Retrieve HTTP headers. | 414 | * Retrieve HTTP headers. |
410 | */ | 415 | */ |
@@ -412,7 +417,7 @@ index 6a64836fb..96ebc298b 100644 | |||
412 | while ((str = get_sanitized_hdr(sfp)) != NULL) { | 417 | while ((str = get_sanitized_hdr(sfp)) != NULL) { |
413 | static const char keywords[] ALIGN1 = | 418 | static const char keywords[] ALIGN1 = |
414 | "content-length\0""transfer-encoding\0""location\0"; | 419 | "content-length\0""transfer-encoding\0""location\0"; |
415 | @@ -1497,6 +1570,7 @@ However, in real world it was observed that some web servers | 420 | @@ -1497,6 +1574,7 @@ However, in real world it was observed that some web servers |
416 | goto establish_session; | 421 | goto establish_session; |
417 | } | 422 | } |
418 | } | 423 | } |
@@ -420,7 +425,7 @@ index 6a64836fb..96ebc298b 100644 | |||
420 | // if (status >= 300) | 425 | // if (status >= 300) |
421 | // bb_error_msg_and_die("bad redirection (no Location: header from server)"); | 426 | // bb_error_msg_and_die("bad redirection (no Location: header from server)"); |
422 | 427 | ||
423 | @@ -1514,6 +1588,7 @@ However, in real world it was observed that some web servers | 428 | @@ -1514,6 +1592,7 @@ However, in real world it was observed that some web servers |
424 | 429 | ||
425 | free(lsa); | 430 | free(lsa); |
426 | 431 | ||
@@ -428,7 +433,7 @@ index 6a64836fb..96ebc298b 100644 | |||
428 | if (!(option_mask32 & WGET_OPT_SPIDER)) { | 433 | if (!(option_mask32 & WGET_OPT_SPIDER)) { |
429 | if (G.output_fd < 0) | 434 | if (G.output_fd < 0) |
430 | G.output_fd = xopen(G.fname_out, G.o_flags); | 435 | G.output_fd = xopen(G.fname_out, G.o_flags); |
431 | @@ -1536,6 +1611,7 @@ However, in real world it was observed that some web servers | 436 | @@ -1536,6 +1615,7 @@ However, in real world it was observed that some web servers |
432 | /* ftpcmd("QUIT", NULL, sfp); - why bother? */ | 437 | /* ftpcmd("QUIT", NULL, sfp); - why bother? */ |
433 | } | 438 | } |
434 | #endif | 439 | #endif |
@@ -436,7 +441,7 @@ index 6a64836fb..96ebc298b 100644 | |||
436 | fclose(sfp); | 441 | fclose(sfp); |
437 | 442 | ||
438 | free(server.allocated); | 443 | free(server.allocated); |
439 | @@ -1544,11 +1620,13 @@ However, in real world it was observed that some web servers | 444 | @@ -1544,11 +1624,13 @@ However, in real world it was observed that some web servers |
440 | free(target.user); | 445 | free(target.user); |
441 | free(fname_out_alloc); | 446 | free(fname_out_alloc); |
442 | free(redirected_path); | 447 | free(redirected_path); |
@@ -450,7 +455,7 @@ index 6a64836fb..96ebc298b 100644 | |||
450 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS | 455 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS |
451 | static const char wget_longopts[] ALIGN1 = | 456 | static const char wget_longopts[] ALIGN1 = |
452 | /* name, has_arg, val */ | 457 | /* name, has_arg, val */ |
453 | @@ -1590,6 +1668,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") | 458 | @@ -1590,6 +1672,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") |
454 | #endif | 459 | #endif |
455 | 460 | ||
456 | INIT_G(); | 461 | INIT_G(); |
@@ -458,7 +463,7 @@ index 6a64836fb..96ebc298b 100644 | |||
458 | 463 | ||
459 | #if ENABLE_FEATURE_WGET_TIMEOUT | 464 | #if ENABLE_FEATURE_WGET_TIMEOUT |
460 | G.timeout_seconds = 900; | 465 | G.timeout_seconds = 900; |
461 | @@ -1626,6 +1705,8 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") | 466 | @@ -1626,6 +1709,8 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") |
462 | IF_FEATURE_WGET_LONG_OPTIONS(, &G.post_data) | 467 | IF_FEATURE_WGET_LONG_OPTIONS(, &G.post_data) |
463 | IF_FEATURE_WGET_LONG_OPTIONS(, &G.post_file) | 468 | IF_FEATURE_WGET_LONG_OPTIONS(, &G.post_file) |
464 | ); | 469 | ); |
@@ -467,7 +472,7 @@ index 6a64836fb..96ebc298b 100644 | |||
467 | #if 0 /* option bits debug */ | 472 | #if 0 /* option bits debug */ |
468 | if (option_mask32 & WGET_OPT_RETRIES) bb_error_msg("-t NUM"); | 473 | if (option_mask32 & WGET_OPT_RETRIES) bb_error_msg("-t NUM"); |
469 | if (option_mask32 & WGET_OPT_nsomething) bb_error_msg("-nsomething"); | 474 | if (option_mask32 & WGET_OPT_nsomething) bb_error_msg("-nsomething"); |
470 | @@ -1670,6 +1751,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") | 475 | @@ -1670,6 +1755,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") |
471 | } | 476 | } |
472 | #endif | 477 | #endif |
473 | 478 | ||
@@ -475,7 +480,7 @@ index 6a64836fb..96ebc298b 100644 | |||
475 | G.output_fd = -1; | 480 | G.output_fd = -1; |
476 | G.o_flags = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL; | 481 | G.o_flags = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL; |
477 | if (G.fname_out) { /* -O FILE ? */ | 482 | if (G.fname_out) { /* -O FILE ? */ |
478 | @@ -1691,8 +1773,11 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") | 483 | @@ -1691,8 +1777,11 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") |
479 | } | 484 | } |
480 | } | 485 | } |
481 | 486 | ||