diff options
| author | Alexander M Pickering <alex@cogarr.net> | 2024-11-11 15:28:11 -0600 |
|---|---|---|
| committer | Alexander M Pickering <alex@cogarr.net> | 2024-11-11 15:28:11 -0600 |
| commit | fa8da3513615d2a2feda7cce294f056078437ba6 (patch) | |
| tree | a897bd2251101258e358ebed0ddc958537081e81 | |
| parent | 70d3399b58a8b4d8a5206bb82ed45c6933e83346 (diff) | |
| download | busybox-w32-packaging-fa8da3513615d2a2feda7cce294f056078437ba6.tar.gz busybox-w32-packaging-fa8da3513615d2a2feda7cce294f056078437ba6.tar.bz2 busybox-w32-packaging-fa8da3513615d2a2feda7cce294f056078437ba6.zip | |
More error reporting
| -rw-r--r-- | libressl.patch | 64 |
1 files changed, 40 insertions, 24 deletions
diff --git a/libressl.patch b/libressl.patch index d8a5430..d10206f 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..33d5ff2d5 100644 | 138 | index 6a64836fb..99d0233ba 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,11 @@ | 141 | @@ -169,7 +169,11 @@ |
| @@ -305,7 +305,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 305 | /*G.content_len = 0; - redundant, got_clen = 0 is enough */ | 305 | /*G.content_len = 0; - redundant, got_clen = 0 is enough */ |
| 306 | G.got_clen = 0; | 306 | G.got_clen = 0; |
| 307 | G.chunked = 0; | 307 | G.chunked = 0; |
| 308 | @@ -1229,37 +1300,58 @@ static void download_one_url(const char *url) | 308 | @@ -1229,37 +1300,59 @@ static void download_one_url(const char *url) |
| 309 | 309 | ||
| 310 | /* Open socket to http(s) server */ | 310 | /* Open socket to http(s) server */ |
| 311 | #if ENABLE_FEATURE_WGET_OPENSSL | 311 | #if ENABLE_FEATURE_WGET_OPENSSL |
| @@ -330,16 +330,17 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 330 | + servername = xstrdup(host); | 330 | + servername = xstrdup(host); |
| 331 | + ctx = tls_client(); | 331 | + ctx = tls_client(); |
| 332 | + if(ctx == NULL) | 332 | + if(ctx == NULL) |
| 333 | + bb_error_msg_and_die("Out of memory 1"); | 333 | + bb_error_msg_and_die("Out of memory 1"); |
| 334 | + struct tls_config *config; | 334 | + struct tls_config *config; |
| 335 | + config = tls_config_new(); | 335 | + config = tls_config_new(); |
| 336 | + if(config == NULL) | 336 | + if(config == NULL) |
| 337 | + bb_error_msg_and_die("Out of memory 2"); | 337 | + bb_error_msg_and_die("Out of memory 2"); |
| 338 | + if(tls_configure(ctx,config) != 0) | 338 | + if(tls_configure(ctx,config) != 0) |
| 339 | + bb_error_msg_and_die("Failed to configure client"); | 339 | + bb_error_msg_and_die("Failed to configure client"); |
| 340 | + sfp = tmpfile(); | 340 | + sfp = tmpfile(); |
| 341 | + dfp = tmpfile(); | 341 | + dfp = tmpfile(); |
| 342 | + tls_connect_fds(ctx, dfp, sfp, servername); | 342 | + if(tls_connect_fds(ctx, dfp, sfp, servername) != 0) |
| 343 | + bb_error_msg_and_die("Failed to connect: %s", tls_error(ctx)); | ||
| 343 | + tls_config_free(config); | 344 | + tls_config_free(config); |
| 344 | + free(allocated); | 345 | + free(allocated); |
| 345 | + free(servername); | 346 | + free(servername); |
| @@ -377,7 +378,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 377 | /* Send HTTP request */ | 378 | /* Send HTTP request */ |
| 378 | if (use_proxy) { | 379 | if (use_proxy) { |
| 379 | SENDFMT(sfp, "GET %s://%s/%s HTTP/1.1\r\n", | 380 | SENDFMT(sfp, "GET %s://%s/%s HTTP/1.1\r\n", |
| 380 | @@ -1270,6 +1362,7 @@ static void download_one_url(const char *url) | 381 | @@ -1270,6 +1363,7 @@ static void download_one_url(const char *url) |
| 381 | (option_mask32 & WGET_OPT_POST) ? "POST" : "GET", | 382 | (option_mask32 & WGET_OPT_POST) ? "POST" : "GET", |
| 382 | target.path); | 383 | target.path); |
| 383 | } | 384 | } |
| @@ -385,7 +386,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 385 | if (!USR_HEADER_HOST) | 386 | if (!USR_HEADER_HOST) |
| 386 | SENDFMT(sfp, "Host: %s\r\n", target.host); | 387 | SENDFMT(sfp, "Host: %s\r\n", target.host); |
| 387 | if (!USR_HEADER_USER_AGENT) | 388 | if (!USR_HEADER_USER_AGENT) |
| 388 | @@ -1280,6 +1373,7 @@ static void download_one_url(const char *url) | 389 | @@ -1280,6 +1374,7 @@ static void download_one_url(const char *url) |
| 389 | */ | 390 | */ |
| 390 | SENDFMT(sfp, "Connection: close\r\n"); | 391 | SENDFMT(sfp, "Connection: close\r\n"); |
| 391 | 392 | ||
| @@ -393,7 +394,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 393 | #if ENABLE_FEATURE_WGET_AUTHENTICATION | 394 | #if ENABLE_FEATURE_WGET_AUTHENTICATION |
| 394 | if (target.user && !USR_HEADER_AUTH) { | 395 | if (target.user && !USR_HEADER_AUTH) { |
| 395 | SENDFMT(sfp, "Proxy-Authorization: Basic %s\r\n"+6, | 396 | SENDFMT(sfp, "Proxy-Authorization: Basic %s\r\n"+6, |
| 396 | @@ -1291,6 +1385,7 @@ static void download_one_url(const char *url) | 397 | @@ -1291,6 +1386,7 @@ static void download_one_url(const char *url) |
| 397 | } | 398 | } |
| 398 | #endif | 399 | #endif |
| 399 | 400 | ||
| @@ -401,7 +402,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 401 | if (G.beg_range != 0 && !USR_HEADER_RANGE) | 402 | if (G.beg_range != 0 && !USR_HEADER_RANGE) |
| 402 | SENDFMT(sfp, "Range: bytes=%"OFF_FMT"u-\r\n", G.beg_range); | 403 | SENDFMT(sfp, "Range: bytes=%"OFF_FMT"u-\r\n", G.beg_range); |
| 403 | 404 | ||
| 404 | @@ -1300,6 +1395,7 @@ static void download_one_url(const char *url) | 405 | @@ -1300,6 +1396,7 @@ static void download_one_url(const char *url) |
| 405 | fputs(G.extra_headers, sfp); | 406 | fputs(G.extra_headers, sfp); |
| 406 | } | 407 | } |
| 407 | 408 | ||
| @@ -409,7 +410,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 409 | if (option_mask32 & WGET_OPT_POST_FILE) { | 410 | if (option_mask32 & WGET_OPT_POST_FILE) { |
| 410 | int fd = xopen_stdin(G.post_file); | 411 | int fd = xopen_stdin(G.post_file); |
| 411 | G.post_data = xmalloc_read(fd, NULL); | 412 | G.post_data = xmalloc_read(fd, NULL); |
| 412 | @@ -1314,15 +1410,18 @@ static void download_one_url(const char *url) | 413 | @@ -1314,15 +1411,18 @@ static void download_one_url(const char *url) |
| 413 | ); | 414 | ); |
| 414 | } | 415 | } |
| 415 | # if ENABLE_PLATFORM_MINGW32 | 416 | # if ENABLE_PLATFORM_MINGW32 |
| @@ -428,7 +429,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 428 | } else | 429 | } else |
| 429 | # else | 430 | # else |
| 430 | SENDFMT(sfp, | 431 | SENDFMT(sfp, |
| 431 | @@ -1338,6 +1437,7 @@ static void download_one_url(const char *url) | 432 | @@ -1338,6 +1438,7 @@ static void download_one_url(const char *url) |
| 432 | SENDFMT(sfp, "\r\n"); | 433 | SENDFMT(sfp, "\r\n"); |
| 433 | } | 434 | } |
| 434 | 435 | ||
| @@ -436,12 +437,27 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 436 | fflush(sfp); | 437 | fflush(sfp); |
| 437 | 438 | ||
| 438 | /* Tried doing this unconditionally. | 439 | /* Tried doing this unconditionally. |
| 439 | @@ -1358,14 +1458,23 @@ static void download_one_url(const char *url) | 440 | @@ -1345,27 +1446,38 @@ static void download_one_url(const char *url) |
| 441 | */ | ||
| 442 | #if SSL_SUPPORTED | ||
| 443 | if (target.protocol == P_HTTPS) { | ||
| 444 | + printf("wget download_one_url 26-2\n"); | ||
| 445 | /* If we use SSL helper, keeping our end of the socket open for writing | ||
| 446 | * makes our end (i.e. the same fd!) readable (EAGAIN instead of EOF) | ||
| 447 | * even after child closes its copy of the fd. | ||
| 448 | * This helps: | ||
| 449 | */ | ||
| 450 | shutdown(fileno(sfp), SHUT_WR); | ||
| 451 | + printf("wget download_one_url 26-3\n"); | ||
| 452 | } | ||
| 453 | #endif | ||
| 454 | |||
| 455 | + rewind(dfp); | ||
| 456 | + sfp = dfp; | ||
| 457 | /* | ||
| 440 | * Retrieve HTTP response line and check for "200" status code. | 458 | * Retrieve HTTP response line and check for "200" status code. |
| 441 | */ | 459 | */ |
| 442 | read_response: | 460 | read_response: |
| 443 | + rewind(dfp); | ||
| 444 | + sfp = dfp; | ||
| 445 | + printf("wget download_one_url 27\n"); | 461 | + printf("wget download_one_url 27\n"); |
| 446 | fgets_trim_sanitize(sfp, " %s\n"); | 462 | fgets_trim_sanitize(sfp, " %s\n"); |
| 447 | + printf("wget download_one_url 27-1\n"); | 463 | + printf("wget download_one_url 27-1\n"); |
| @@ -460,7 +476,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 460 | switch (status) { | 476 | switch (status) { |
| 461 | case 0: | 477 | case 0: |
| 462 | case 100: | 478 | case 100: |
| 463 | @@ -1441,6 +1550,7 @@ However, in real world it was observed that some web servers | 479 | @@ -1441,6 +1553,7 @@ However, in real world it was observed that some web servers |
| 464 | /* | 480 | /* |
| 465 | * Retrieve HTTP headers. | 481 | * Retrieve HTTP headers. |
| 466 | */ | 482 | */ |
| @@ -468,7 +484,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 468 | while ((str = get_sanitized_hdr(sfp)) != NULL) { | 484 | while ((str = get_sanitized_hdr(sfp)) != NULL) { |
| 469 | static const char keywords[] ALIGN1 = | 485 | static const char keywords[] ALIGN1 = |
| 470 | "content-length\0""transfer-encoding\0""location\0"; | 486 | "content-length\0""transfer-encoding\0""location\0"; |
| 471 | @@ -1497,6 +1607,7 @@ However, in real world it was observed that some web servers | 487 | @@ -1497,6 +1610,7 @@ However, in real world it was observed that some web servers |
| 472 | goto establish_session; | 488 | goto establish_session; |
| 473 | } | 489 | } |
| 474 | } | 490 | } |
| @@ -476,7 +492,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 476 | // if (status >= 300) | 492 | // if (status >= 300) |
| 477 | // bb_error_msg_and_die("bad redirection (no Location: header from server)"); | 493 | // bb_error_msg_and_die("bad redirection (no Location: header from server)"); |
| 478 | 494 | ||
| 479 | @@ -1514,6 +1625,7 @@ However, in real world it was observed that some web servers | 495 | @@ -1514,6 +1628,7 @@ However, in real world it was observed that some web servers |
| 480 | 496 | ||
| 481 | free(lsa); | 497 | free(lsa); |
| 482 | 498 | ||
| @@ -484,7 +500,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 484 | if (!(option_mask32 & WGET_OPT_SPIDER)) { | 500 | if (!(option_mask32 & WGET_OPT_SPIDER)) { |
| 485 | if (G.output_fd < 0) | 501 | if (G.output_fd < 0) |
| 486 | G.output_fd = xopen(G.fname_out, G.o_flags); | 502 | G.output_fd = xopen(G.fname_out, G.o_flags); |
| 487 | @@ -1536,6 +1648,7 @@ However, in real world it was observed that some web servers | 503 | @@ -1536,6 +1651,7 @@ However, in real world it was observed that some web servers |
| 488 | /* ftpcmd("QUIT", NULL, sfp); - why bother? */ | 504 | /* ftpcmd("QUIT", NULL, sfp); - why bother? */ |
| 489 | } | 505 | } |
| 490 | #endif | 506 | #endif |
| @@ -492,7 +508,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 492 | fclose(sfp); | 508 | fclose(sfp); |
| 493 | 509 | ||
| 494 | free(server.allocated); | 510 | free(server.allocated); |
| 495 | @@ -1544,11 +1657,13 @@ However, in real world it was observed that some web servers | 511 | @@ -1544,11 +1660,13 @@ However, in real world it was observed that some web servers |
| 496 | free(target.user); | 512 | free(target.user); |
| 497 | free(fname_out_alloc); | 513 | free(fname_out_alloc); |
| 498 | free(redirected_path); | 514 | free(redirected_path); |
| @@ -506,7 +522,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 506 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS | 522 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS |
| 507 | static const char wget_longopts[] ALIGN1 = | 523 | static const char wget_longopts[] ALIGN1 = |
| 508 | /* name, has_arg, val */ | 524 | /* name, has_arg, val */ |
| 509 | @@ -1590,6 +1705,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") | 525 | @@ -1590,6 +1708,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") |
| 510 | #endif | 526 | #endif |
| 511 | 527 | ||
| 512 | INIT_G(); | 528 | INIT_G(); |
| @@ -514,7 +530,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 514 | 530 | ||
| 515 | #if ENABLE_FEATURE_WGET_TIMEOUT | 531 | #if ENABLE_FEATURE_WGET_TIMEOUT |
| 516 | G.timeout_seconds = 900; | 532 | G.timeout_seconds = 900; |
| 517 | @@ -1626,6 +1742,8 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") | 533 | @@ -1626,6 +1745,8 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") |
| 518 | IF_FEATURE_WGET_LONG_OPTIONS(, &G.post_data) | 534 | IF_FEATURE_WGET_LONG_OPTIONS(, &G.post_data) |
| 519 | IF_FEATURE_WGET_LONG_OPTIONS(, &G.post_file) | 535 | IF_FEATURE_WGET_LONG_OPTIONS(, &G.post_file) |
| 520 | ); | 536 | ); |
| @@ -523,7 +539,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 523 | #if 0 /* option bits debug */ | 539 | #if 0 /* option bits debug */ |
| 524 | if (option_mask32 & WGET_OPT_RETRIES) bb_error_msg("-t NUM"); | 540 | if (option_mask32 & WGET_OPT_RETRIES) bb_error_msg("-t NUM"); |
| 525 | if (option_mask32 & WGET_OPT_nsomething) bb_error_msg("-nsomething"); | 541 | if (option_mask32 & WGET_OPT_nsomething) bb_error_msg("-nsomething"); |
| 526 | @@ -1670,6 +1788,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") | 542 | @@ -1670,6 +1791,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") |
| 527 | } | 543 | } |
| 528 | #endif | 544 | #endif |
| 529 | 545 | ||
| @@ -531,7 +547,7 @@ index 6a64836fb..33d5ff2d5 100644 | |||
| 531 | G.output_fd = -1; | 547 | G.output_fd = -1; |
| 532 | G.o_flags = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL; | 548 | G.o_flags = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL; |
| 533 | if (G.fname_out) { /* -O FILE ? */ | 549 | if (G.fname_out) { /* -O FILE ? */ |
| 534 | @@ -1691,8 +1810,11 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") | 550 | @@ -1691,8 +1813,11 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") |
| 535 | } | 551 | } |
| 536 | } | 552 | } |
| 537 | 553 | ||
