91 lines
2.7 KiB
Diff
91 lines
2.7 KiB
Diff
From 26247a0d7e24c06d5b250f044a951441674a4484 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Stenberg <daniel@haxx.se>
|
|
Date: Sat, 13 Nov 2021 14:13:20 +0100
|
|
Subject: [PATCH 1/1] lib1939: make it endure torture tests
|
|
|
|
Follow-up to f0b7099a10d1a
|
|
|
|
Closes #8007
|
|
|
|
Conflict:NA
|
|
Reference:https://github.com/curl/curl/commit/26247a0d7e24c06d5b250f044a951441674a4484
|
|
---
|
|
tests/libtest/lib1939.c | 55 +++++++++++++++++++----------------------
|
|
1 file changed, 26 insertions(+), 29 deletions(-)
|
|
|
|
diff --git a/tests/libtest/lib1939.c b/tests/libtest/lib1939.c
|
|
index 644617712..510215dbd 100644
|
|
--- a/tests/libtest/lib1939.c
|
|
+++ b/tests/libtest/lib1939.c
|
|
@@ -33,41 +33,38 @@ int test(char *URL)
|
|
curl_global_init(CURL_GLOBAL_DEFAULT);
|
|
|
|
multi = curl_multi_init();
|
|
- if(!multi)
|
|
- return 1;
|
|
+ if(multi) {
|
|
+ easy = curl_easy_init();
|
|
+ if(easy) {
|
|
+ CURLcode c;
|
|
+ CURLMcode m;
|
|
|
|
- easy = curl_easy_init();
|
|
- if(easy) {
|
|
- CURLcode c;
|
|
- CURLMcode m;
|
|
+ /* Crash only happens when using HTTPS */
|
|
+ c = curl_easy_setopt(easy, CURLOPT_URL, URL);
|
|
+ if(!c)
|
|
+ /* Any old HTTP tunneling proxy will do here */
|
|
+ c = curl_easy_setopt(easy, CURLOPT_PROXY, libtest_arg2);
|
|
|
|
- /* Crash only happens when using HTTPS */
|
|
- c = curl_easy_setopt(easy, CURLOPT_URL, URL);
|
|
- if(!c)
|
|
- /* Any old HTTP tunneling proxy will do here */
|
|
- c = curl_easy_setopt(easy, CURLOPT_PROXY, libtest_arg2);
|
|
+ if(!c) {
|
|
|
|
- if(c)
|
|
- return 2;
|
|
+ /* We're going to drive the transfer using multi interface here,
|
|
+ because we want to stop during the middle. */
|
|
+ m = curl_multi_add_handle(multi, easy);
|
|
|
|
- /* We're going to drive the transfer using multi interface here, because we
|
|
- want to stop during the middle. */
|
|
- m = curl_multi_add_handle(multi, easy);
|
|
+ if(!m)
|
|
+ /* Run the multi handle once, just enough to start establishing an
|
|
+ HTTPS connection. */
|
|
+ m = curl_multi_perform(multi, &running_handles);
|
|
|
|
- if(!m)
|
|
- /* Run the multi handle once, just enough to start establishing an HTTPS
|
|
- connection. */
|
|
- m = curl_multi_perform(multi, &running_handles);
|
|
-
|
|
- if(m)
|
|
- return 3;
|
|
-
|
|
- /* Close the easy handle *before* the multi handle. Doing it the other way
|
|
- around avoids the issue. */
|
|
- curl_easy_cleanup(easy);
|
|
+ if(m)
|
|
+ fprintf(stderr, "curl_multi_perform failed\n");
|
|
+ }
|
|
+ /* Close the easy handle *before* the multi handle. Doing it the other
|
|
+ way around avoids the issue. */
|
|
+ curl_easy_cleanup(easy);
|
|
+ }
|
|
+ curl_multi_cleanup(multi); /* double-free happens here */
|
|
}
|
|
- curl_multi_cleanup(multi); /* double-free happens here */
|
|
-
|
|
curl_global_cleanup();
|
|
return CURLE_OK;
|
|
}
|
|
--
|
|
2.33.0
|
|
|