summaryrefslogtreecommitdiff
path: root/lib/connect.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2022-08-08 12:36:41 +0200
committerDaniel Stenberg <daniel@haxx.se>2022-08-08 13:26:11 +0200
commit0f23341953d1000ef55949519fa58d5f00759bbb (patch)
tree70869737817347eec0388d1cb804df526a783edf /lib/connect.c
parenta041ed8cde7b67e9d6da4ada0af3826915e8dea7 (diff)
downloadcurl-0f23341953d1000ef55949519fa58d5f00759bbb.tar.gz
connect: set socktype/protocol correctly
So that an address used from the DNS cache that was previously used for QUIC can be reused for TCP and vice versa. To make this possible, set conn->transport to "unix" for unix domain connections ... and store the transport struct field in an unsigned char to use less space. Reported-by: ウさん Fixes #9274 Closes #9276
Diffstat (limited to 'lib/connect.c')
-rw-r--r--lib/connect.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/connect.c b/lib/connect.c
index 68cfe72ef..38f75e09f 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -1604,9 +1604,20 @@ CURLcode Curl_socket(struct Curl_easy *data,
*/
addr->family = ai->ai_family;
- addr->socktype = (conn->transport == TRNSPRT_TCP) ? SOCK_STREAM : SOCK_DGRAM;
- addr->protocol = conn->transport != TRNSPRT_TCP ? IPPROTO_UDP :
- ai->ai_protocol;
+ switch(conn->transport) {
+ case TRNSPRT_TCP:
+ addr->socktype = SOCK_STREAM;
+ addr->protocol = IPPROTO_TCP;
+ break;
+ case TRNSPRT_UNIX:
+ addr->socktype = SOCK_STREAM;
+ addr->protocol = IPPROTO_IP;
+ break;
+ default: /* UDP and QUIC */
+ addr->socktype = SOCK_DGRAM;
+ addr->protocol = IPPROTO_UDP;
+ break;
+ }
addr->addrlen = ai->ai_addrlen;
if(addr->addrlen > sizeof(struct Curl_sockaddr_storage))