Last active
July 31, 2023 14:59
-
-
Save bagder/99aeef7a3c724813b5d736d6605f6d7a to your computer and use it in GitHub Desktop.
patch for Richard W.M. Jones' "Curl segfault in curl_multi_perform"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/url.c b/lib/url.c | |
index 73f2da4ba..8eecfc421 100644 | |
--- a/lib/url.c | |
+++ b/lib/url.c | |
@@ -1071,10 +1071,13 @@ ConnectionExists(struct Curl_easy *data, | |
(needle->handler->protocol & PROTO_FAMILY_HTTP))); | |
#else | |
bool wantProxyNTLMhttp = FALSE; | |
#endif | |
#endif | |
+ /* plain HTTP with upgrade */ | |
+ bool h2upgrade = (data->state.httpwant == CURL_HTTP_VERSION_2_0) && | |
+ (needle->handler->protocol & CURLPROTO_HTTP); | |
*force_reuse = FALSE; | |
*waitpipe = FALSE; | |
/* Look up the bundle with all the connections to this particular host. | |
@@ -1133,11 +1136,11 @@ ConnectionExists(struct Curl_easy *data, | |
Curl_disconnect(data, check, TRUE); | |
continue; | |
} | |
if(data->set.ipver != CURL_IPRESOLVE_WHATEVER | |
- && data->set.ipver != check->ip_version) { | |
+ && data->set.ipver != check->ip_version) { | |
/* skip because the connection is not via the requested IP version */ | |
continue; | |
} | |
if(bundle->multiuse == BUNDLE_MULTIPLEX) | |
@@ -1231,10 +1234,21 @@ ConnectionExists(struct Curl_easy *data, | |
continue; | |
} | |
} | |
#endif | |
+ if(h2upgrade && !check->httpversion && canmultiplex) { | |
+ if(data->set.pipewait) { | |
+ infof(data, "Server upgrade doesn't support multiplex yet, wait"); | |
+ *waitpipe = TRUE; | |
+ CONNCACHE_UNLOCK(data); | |
+ return FALSE; /* no re-use */ | |
+ } | |
+ infof(data, "Server upgrade cannot be used"); | |
+ continue; /* can't be used atm */ | |
+ } | |
+ | |
if(!canmultiplex && CONN_INUSE(check)) | |
/* this request can't be multiplexed but the checked connection is | |
already in use so we skip it */ | |
continue; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment