diff options
author | Alexander M Pickering <alex@cogarr.net> | 2024-11-22 12:03:50 -0600 |
---|---|---|
committer | Alexander M Pickering <alex@cogarr.net> | 2024-11-22 12:03:50 -0600 |
commit | ed1163f637af4f465e1524db4b09b7010b23498b (patch) | |
tree | a12104a25ce7d49b108308ddbccc47a8d2cb192a | |
parent | b7c998deaba79bb04ab635fd59b273998c4eed10 (diff) | |
download | busybox-w32-packaging-bug/tempfile.tar.gz busybox-w32-packaging-bug/tempfile.tar.bz2 busybox-w32-packaging-bug/tempfile.zip |
Delete temporary files after done.bug/tempfile
-rw-r--r-- | libressl.patch | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/libressl.patch b/libressl.patch index 0b4ea90..22b4089 100644 --- a/libressl.patch +++ b/libressl.patch | |||
@@ -102,7 +102,7 @@ index 9f1dd67ec..60e1afe99 100644 | |||
102 | static void tls_xwrite(tls_state_t *tls, int len) | 102 | static void tls_xwrite(tls_state_t *tls, int len) |
103 | { | 103 | { |
104 | diff --git a/networking/wget.c b/networking/wget.c | 104 | diff --git a/networking/wget.c b/networking/wget.c |
105 | index 6a64836fb..ba818a97b 100644 | 105 | index 6a64836fb..2d9847114 100644 |
106 | --- a/networking/wget.c | 106 | --- a/networking/wget.c |
107 | +++ b/networking/wget.c | 107 | +++ b/networking/wget.c |
108 | @@ -1,4 +1,3 @@ | 108 | @@ -1,4 +1,3 @@ |
@@ -270,7 +270,15 @@ index 6a64836fb..ba818a97b 100644 | |||
270 | #endif | 270 | #endif |
271 | 271 | ||
272 | #if ENABLE_FEATURE_WGET_HTTPS | 272 | #if ENABLE_FEATURE_WGET_HTTPS |
273 | @@ -1151,6 +1210,9 @@ static void download_one_url(const char *url) | 273 | @@ -1139,6 +1198,7 @@ static void download_one_url(const char *url) |
274 | bool use_proxy; /* Use proxies if env vars are set */ | ||
275 | int redir_limit; | ||
276 | len_and_sockaddr *lsa; | ||
277 | + char *sfp_name, *dfp_name; | ||
278 | FILE *sfp; /* socket to web/ftp server */ | ||
279 | FILE *dfp; /* socket to ftp server (data) */ | ||
280 | char *fname_out_alloc; | ||
281 | @@ -1151,6 +1211,9 @@ static void download_one_url(const char *url) | ||
274 | server.user = NULL; | 282 | server.user = NULL; |
275 | target.user = NULL; | 283 | target.user = NULL; |
276 | 284 | ||
@@ -280,7 +288,7 @@ index 6a64836fb..ba818a97b 100644 | |||
280 | parse_url(url, &target); | 288 | parse_url(url, &target); |
281 | 289 | ||
282 | /* Use the proxy if necessary */ | 290 | /* Use the proxy if necessary */ |
283 | @@ -1234,22 +1296,46 @@ static void download_one_url(const char *url) | 291 | @@ -1234,22 +1297,44 @@ static void download_one_url(const char *url) |
284 | /* openssl-based helper | 292 | /* openssl-based helper |
285 | * Inconvenient API since we can't give it an open fd | 293 | * Inconvenient API since we can't give it an open fd |
286 | */ | 294 | */ |
@@ -302,15 +310,14 @@ index 6a64836fb..ba818a97b 100644 | |||
302 | + bb_error_msg_and_die("Out of memory 1"); | 310 | + bb_error_msg_and_die("Out of memory 1"); |
303 | + if(tls_configure(ctx,G.tlscfg) != 0) | 311 | + if(tls_configure(ctx,G.tlscfg) != 0) |
304 | + bb_error_msg_and_die("Failed to configure client"); | 312 | + bb_error_msg_and_die("Failed to configure client"); |
305 | + char *sfp_name = _tempnam(NULL,"l4w"); | 313 | + sfp_name = _tempnam(NULL,"l4w"); |
306 | + if(sfp_name == NULL) | 314 | + if(sfp_name == NULL) |
307 | + bb_error_msg_and_die("Failed to generate tmpfile name for sfp"); | 315 | + bb_error_msg_and_die("Failed to generate tmpfile name for sfp"); |
308 | + printf("Source file name:%s\n",sfp_name); | 316 | + printf("Source file name:%s\n",sfp_name); |
309 | + sfp = fopen(sfp_name, "w+"); | 317 | + sfp = fopen(sfp_name, "w+"); |
310 | + if(sfp == NULL) | 318 | + if(sfp == NULL) |
311 | + bb_error_msg_and_die("Failed to open source tempfile %d: %s", errno, strerror(errno)); | 319 | + bb_error_msg_and_die("Failed to open source tempfile %d: %s", errno, strerror(errno)); |
312 | + free(sfp_name); | 320 | + dfp_name = _tempnam(NULL,"l4w"); |
313 | + char *dfp_name = _tempnam(NULL,"l4w"); | ||
314 | + if(dfp_name == NULL) | 321 | + if(dfp_name == NULL) |
315 | + bb_error_msg_and_die("Failed to generate tmpfile name for dfp"); | 322 | + bb_error_msg_and_die("Failed to generate tmpfile name for dfp"); |
316 | + dfp = fopen(dfp_name, "w+"); | 323 | + dfp = fopen(dfp_name, "w+"); |
@@ -318,7 +325,6 @@ index 6a64836fb..ba818a97b 100644 | |||
318 | + //dfp = tmpfile(); | 325 | + //dfp = tmpfile(); |
319 | + if(dfp == NULL) | 326 | + if(dfp == NULL) |
320 | + bb_error_msg_and_die("Failed to open source tempfile %d: %s", errno, strerror(errno)); | 327 | + bb_error_msg_and_die("Failed to open source tempfile %d: %s", errno, strerror(errno)); |
321 | + free(dfp_name); | ||
322 | + if(tls_connect(ctx, servername, NULL) != 0) | 328 | + if(tls_connect(ctx, servername, NULL) != 0) |
323 | + bb_error_msg_and_die("Failed to connect: %s", tls_error(ctx)); | 329 | + bb_error_msg_and_die("Failed to connect: %s", tls_error(ctx)); |
324 | + free(allocated); | 330 | + free(allocated); |
@@ -337,7 +343,7 @@ index 6a64836fb..ba818a97b 100644 | |||
337 | socket_opened: | 343 | socket_opened: |
338 | #elif ENABLE_FEATURE_WGET_HTTPS | 344 | #elif ENABLE_FEATURE_WGET_HTTPS |
339 | /* Only internal TLS support is configured */ | 345 | /* Only internal TLS support is configured */ |
340 | @@ -1353,7 +1439,42 @@ static void download_one_url(const char *url) | 346 | @@ -1353,7 +1438,44 @@ static void download_one_url(const char *url) |
341 | shutdown(fileno(sfp), SHUT_WR); | 347 | shutdown(fileno(sfp), SHUT_WR); |
342 | } | 348 | } |
343 | #endif | 349 | #endif |
@@ -376,12 +382,14 @@ index 6a64836fb..ba818a97b 100644 | |||
376 | + bb_error_msg_and_die("tls read error: %s", tls_error(ctx)); | 382 | + bb_error_msg_and_die("tls read error: %s", tls_error(ctx)); |
377 | + rewind(dfp); | 383 | + rewind(dfp); |
378 | + fclose(sfp); | 384 | + fclose(sfp); |
385 | + DeleteFile(sfp_name); | ||
386 | + free(sfp_name); | ||
379 | + sfp = dfp; | 387 | + sfp = dfp; |
380 | + printf("finished in/out exchange\n"); | 388 | + printf("finished in/out exchange\n"); |
381 | /* | 389 | /* |
382 | * Retrieve HTTP response line and check for "200" status code. | 390 | * Retrieve HTTP response line and check for "200" status code. |
383 | */ | 391 | */ |
384 | @@ -1474,7 +1595,7 @@ However, in real world it was observed that some web servers | 392 | @@ -1474,7 +1596,7 @@ However, in real world it was observed that some web servers |
385 | if (key == KEY_location && status >= 300) { | 393 | if (key == KEY_location && status >= 300) { |
386 | if (--redir_limit == 0) | 394 | if (--redir_limit == 0) |
387 | bb_simple_error_msg_and_die("too many redirections"); | 395 | bb_simple_error_msg_and_die("too many redirections"); |
@@ -390,7 +398,7 @@ index 6a64836fb..ba818a97b 100644 | |||
390 | if (str[0] == '/') { | 398 | if (str[0] == '/') { |
391 | free(redirected_path); | 399 | free(redirected_path); |
392 | target.path = redirected_path = xstrdup(str + 1); | 400 | target.path = redirected_path = xstrdup(str + 1); |
393 | @@ -1536,6 +1657,10 @@ However, in real world it was observed that some web servers | 401 | @@ -1536,7 +1658,13 @@ However, in real world it was observed that some web servers |
394 | /* ftpcmd("QUIT", NULL, sfp); - why bother? */ | 402 | /* ftpcmd("QUIT", NULL, sfp); - why bother? */ |
395 | } | 403 | } |
396 | #endif | 404 | #endif |
@@ -399,9 +407,12 @@ index 6a64836fb..ba818a97b 100644 | |||
399 | + tls_close(ctx); | 407 | + tls_close(ctx); |
400 | + printf("Cleaned up connection\n"); | 408 | + printf("Cleaned up connection\n"); |
401 | fclose(sfp); | 409 | fclose(sfp); |
410 | + DeleteFile(dfp_name); | ||
411 | + free(dfp_name); | ||
402 | 412 | ||
403 | free(server.allocated); | 413 | free(server.allocated); |
404 | @@ -1690,9 +1815,18 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") | 414 | free(target.allocated); |
415 | @@ -1690,9 +1818,18 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") | ||
405 | xdup2(G.log_fd, STDERR_FILENO); | 416 | xdup2(G.log_fd, STDERR_FILENO); |
406 | } | 417 | } |
407 | } | 418 | } |
@@ -421,7 +432,7 @@ index 6a64836fb..ba818a97b 100644 | |||
421 | 432 | ||
422 | if (G.output_fd >= 0) | 433 | if (G.output_fd >= 0) |
423 | xclose(G.output_fd); | 434 | xclose(G.output_fd); |
424 | @@ -1704,6 +1838,6 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") | 435 | @@ -1704,6 +1841,6 @@ IF_DESKTOP( "no-parent\0" No_argument "\xf0") |
425 | free(G.extra_headers); | 436 | free(G.extra_headers); |
426 | #endif | 437 | #endif |
427 | FINI_G(); | 438 | FINI_G(); |