From 715149e2011bd89f30440c8e62d7cff8e5968ad4 Mon Sep 17 00:00:00 2001 From: Alexander M Pickering Date: Fri, 8 Nov 2024 17:24:20 -0600 Subject: more debugging --- libressl.patch | 85 +++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 61 insertions(+), 24 deletions(-) diff --git a/libressl.patch b/libressl.patch index b359476..24963ac 100644 --- a/libressl.patch +++ b/libressl.patch @@ -135,7 +135,7 @@ index 9f1dd67ec..7e8da6df2 100644 static void tls_xwrite(tls_state_t *tls, int len) { diff --git a/networking/wget.c b/networking/wget.c -index 6a64836fb..39a69d0b7 100644 +index 6a64836fb..96ebc298b 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -169,7 +169,8 @@ @@ -148,7 +148,44 @@ index 6a64836fb..39a69d0b7 100644 #if 0 # define log_io(...) bb_error_msg(__VA_ARGS__) # define SENDFMT(fp, fmt, ...) \ -@@ -689,6 +690,7 @@ static void reset_beg_range_to_zero(void) +@@ -488,26 +489,35 @@ static char fgets_trim_sanitize(FILE *fp, const char *fmt) + char c; + char *buf_ptr; + ++ printf("wget fgets_trim_sanitize 1\n"); + set_alarm(); +- if (fgets(G.wget_buf, sizeof(G.wget_buf), fp) == NULL) ++ printf("wget fgets_trim_sanitize 2\n"); ++ if (fgets(G.wget_buf, sizeof(G.wget_buf), fp) == NULL){ + bb_simple_perror_msg_and_die("error getting response"); ++ } + clear_alarm(); + ++ printf("wget fgets_trim_sanitize 3\n"); + buf_ptr = strchrnul(G.wget_buf, '\n'); ++ printf("wget fgets_trim_sanitize 4\n"); + c = *buf_ptr; + #if 1 + /* Disallow any control chars: trim at first char < 0x20 */ ++ printf("wget fgets_trim_sanitize 5\n"); + sanitize_string(G.wget_buf); ++ printf("wget fgets_trim_sanitize 6\n"); + #else + *buf_ptr = '\0'; + buf_ptr = strchrnul(G.wget_buf, '\r'); + *buf_ptr = '\0'; + #endif + ++ printf("wget fgets_trim_sanitize 7\n"); + log_io("< %s", G.wget_buf); + + if (fmt && (option_mask32 & WGET_OPT_SERVER_RESPONSE)) + fprintf(stderr, fmt, G.wget_buf); ++ printf("wget fgets_trim_sanitize 8\n"); + + return c; + } +@@ -689,6 +699,7 @@ static void reset_beg_range_to_zero(void) } #if ENABLE_FEATURE_WGET_OPENSSL @@ -156,7 +193,7 @@ index 6a64836fb..39a69d0b7 100644 static int spawn_https_helper_openssl(const char *host, unsigned port) { char *allocated = NULL; -@@ -777,6 +779,33 @@ static int spawn_https_helper_openssl(const char *host, unsigned port) +@@ -777,6 +788,33 @@ static int spawn_https_helper_openssl(const char *host, unsigned port) # endif return sp[0]; } @@ -190,7 +227,7 @@ index 6a64836fb..39a69d0b7 100644 #endif #if ENABLE_FEATURE_WGET_HTTPS -@@ -1151,6 +1180,7 @@ static void download_one_url(const char *url) +@@ -1151,6 +1189,7 @@ static void download_one_url(const char *url) server.user = NULL; target.user = NULL; @@ -198,7 +235,7 @@ index 6a64836fb..39a69d0b7 100644 parse_url(url, &target); /* Use the proxy if necessary */ -@@ -1172,6 +1202,7 @@ static void download_one_url(const char *url) +@@ -1172,6 +1211,7 @@ static void download_one_url(const char *url) server.host = target.host; } } @@ -206,7 +243,7 @@ index 6a64836fb..39a69d0b7 100644 if (ENABLE_FEATURE_IPV6) strip_ipv6_scope_id(target.host); -@@ -1191,6 +1222,7 @@ static void download_one_url(const char *url) +@@ -1191,6 +1231,7 @@ static void download_one_url(const char *url) G.fname_out = fname_out_alloc = xstrdup(G.fname_out); } } @@ -214,7 +251,7 @@ index 6a64836fb..39a69d0b7 100644 #if ENABLE_FEATURE_WGET_STATUSBAR G.curfile = bb_get_last_path_component_nostrip(G.fname_out); #endif -@@ -1206,15 +1238,19 @@ static void download_one_url(const char *url) +@@ -1206,15 +1247,19 @@ static void download_one_url(const char *url) * We are not sure it exists on remote side */ } @@ -234,7 +271,7 @@ index 6a64836fb..39a69d0b7 100644 /*G.content_len = 0; - redundant, got_clen = 0 is enough */ G.got_clen = 0; G.chunked = 0; -@@ -1229,37 +1265,49 @@ static void download_one_url(const char *url) +@@ -1229,37 +1274,49 @@ static void download_one_url(const char *url) /* Open socket to http(s) server */ #if ENABLE_FEATURE_WGET_OPENSSL @@ -286,7 +323,7 @@ index 6a64836fb..39a69d0b7 100644 /* Send HTTP request */ if (use_proxy) { SENDFMT(sfp, "GET %s://%s/%s HTTP/1.1\r\n", -@@ -1270,6 +1318,7 @@ static void download_one_url(const char *url) +@@ -1270,6 +1327,7 @@ static void download_one_url(const char *url) (option_mask32 & WGET_OPT_POST) ? "POST" : "GET", target.path); } @@ -294,7 +331,7 @@ index 6a64836fb..39a69d0b7 100644 if (!USR_HEADER_HOST) SENDFMT(sfp, "Host: %s\r\n", target.host); if (!USR_HEADER_USER_AGENT) -@@ -1280,6 +1329,7 @@ static void download_one_url(const char *url) +@@ -1280,6 +1338,7 @@ static void download_one_url(const char *url) */ SENDFMT(sfp, "Connection: close\r\n"); @@ -302,7 +339,7 @@ index 6a64836fb..39a69d0b7 100644 #if ENABLE_FEATURE_WGET_AUTHENTICATION if (target.user && !USR_HEADER_AUTH) { SENDFMT(sfp, "Proxy-Authorization: Basic %s\r\n"+6, -@@ -1291,6 +1341,7 @@ static void download_one_url(const char *url) +@@ -1291,6 +1350,7 @@ static void download_one_url(const char *url) } #endif @@ -310,7 +347,7 @@ index 6a64836fb..39a69d0b7 100644 if (G.beg_range != 0 && !USR_HEADER_RANGE) SENDFMT(sfp, "Range: bytes=%"OFF_FMT"u-\r\n", G.beg_range); -@@ -1300,6 +1351,7 @@ static void download_one_url(const char *url) +@@ -1300,6 +1360,7 @@ static void download_one_url(const char *url) fputs(G.extra_headers, sfp); } @@ -318,7 +355,7 @@ index 6a64836fb..39a69d0b7 100644 if (option_mask32 & WGET_OPT_POST_FILE) { int fd = xopen_stdin(G.post_file); G.post_data = xmalloc_read(fd, NULL); -@@ -1314,15 +1366,18 @@ static void download_one_url(const char *url) +@@ -1314,15 +1375,18 @@ static void download_one_url(const char *url) ); } # if ENABLE_PLATFORM_MINGW32 @@ -337,7 +374,7 @@ index 6a64836fb..39a69d0b7 100644 } else # else SENDFMT(sfp, -@@ -1338,6 +1393,7 @@ static void download_one_url(const char *url) +@@ -1338,6 +1402,7 @@ static void download_one_url(const char *url) SENDFMT(sfp, "\r\n"); } @@ -345,7 +382,7 @@ index 6a64836fb..39a69d0b7 100644 fflush(sfp); /* Tried doing this unconditionally. -@@ -1358,14 +1414,21 @@ static void download_one_url(const char *url) +@@ -1358,14 +1423,21 @@ static void download_one_url(const char *url) * Retrieve HTTP response line and check for "200" status code. */ read_response: @@ -367,7 +404,7 @@ index 6a64836fb..39a69d0b7 100644 switch (status) { case 0: case 100: -@@ -1441,6 +1504,7 @@ However, in real world it was observed that some web servers +@@ -1441,6 +1513,7 @@ However, in real world it was observed that some web servers /* * Retrieve HTTP headers. */ @@ -375,7 +412,7 @@ index 6a64836fb..39a69d0b7 100644 while ((str = get_sanitized_hdr(sfp)) != NULL) { static const char keywords[] ALIGN1 = "content-length\0""transfer-encoding\0""location\0"; -@@ -1497,6 +1561,7 @@ However, in real world it was observed that some web servers +@@ -1497,6 +1570,7 @@ However, in real world it was observed that some web servers goto establish_session; } } @@ -383,7 +420,7 @@ index 6a64836fb..39a69d0b7 100644 // if (status >= 300) // bb_error_msg_and_die("bad redirection (no Location: header from server)"); -@@ -1514,6 +1579,7 @@ However, in real world it was observed that some web servers +@@ -1514,6 +1588,7 @@ However, in real world it was observed that some web servers free(lsa); @@ -391,7 +428,7 @@ index 6a64836fb..39a69d0b7 100644 if (!(option_mask32 & WGET_OPT_SPIDER)) { if (G.output_fd < 0) G.output_fd = xopen(G.fname_out, G.o_flags); -@@ -1536,6 +1602,7 @@ However, in real world it was observed that some web servers +@@ -1536,6 +1611,7 @@ However, in real world it was observed that some web servers /* ftpcmd("QUIT", NULL, sfp); - why bother? */ } #endif @@ -399,7 +436,7 @@ index 6a64836fb..39a69d0b7 100644 fclose(sfp); free(server.allocated); -@@ -1544,11 +1611,13 @@ However, in real world it was observed that some web servers +@@ -1544,11 +1620,13 @@ However, in real world it was observed that some web servers free(target.user); free(fname_out_alloc); free(redirected_path); @@ -413,7 +450,7 @@ index 6a64836fb..39a69d0b7 100644 #if ENABLE_FEATURE_WGET_LONG_OPTIONS static const char wget_longopts[] ALIGN1 = /* name, has_arg, val */ -@@ -1590,6 +1659,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") +@@ -1590,6 +1668,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") #endif INIT_G(); @@ -421,7 +458,7 @@ index 6a64836fb..39a69d0b7 100644 #if ENABLE_FEATURE_WGET_TIMEOUT G.timeout_seconds = 900; -@@ -1626,6 +1696,8 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") +@@ -1626,6 +1705,8 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") IF_FEATURE_WGET_LONG_OPTIONS(, &G.post_data) IF_FEATURE_WGET_LONG_OPTIONS(, &G.post_file) ); @@ -430,7 +467,7 @@ index 6a64836fb..39a69d0b7 100644 #if 0 /* option bits debug */ if (option_mask32 & WGET_OPT_RETRIES) bb_error_msg("-t NUM"); if (option_mask32 & WGET_OPT_nsomething) bb_error_msg("-nsomething"); -@@ -1670,6 +1742,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") +@@ -1670,6 +1751,7 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") } #endif @@ -438,7 +475,7 @@ index 6a64836fb..39a69d0b7 100644 G.output_fd = -1; G.o_flags = O_WRONLY | O_CREAT | O_TRUNC | O_EXCL; if (G.fname_out) { /* -O FILE ? */ -@@ -1691,8 +1764,11 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") +@@ -1691,8 +1773,11 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") } } -- cgit v1.2.3-55-g6feb