]> granicus.if.org Git - curl/commitdiff
connect: use UDP correctly
authorDaniel Stenberg <daniel@haxx.se>
Mon, 10 Jan 2011 23:14:36 +0000 (00:14 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 10 Jan 2011 23:14:36 +0000 (00:14 +0100)
The idea that the protocol and socktype is part of name resolving in the
libc functions is nuts. We keep the name resolver functions assume
TCP/STREAM and we make sure that when we want to connect to a UDP
service we use the correct UDP/DGRAM set instead. This bug was because
the ->protocol field was not always set correctly.

This bug was only affecting ipv6-disabled non-cares non-threaded builds.

Bug: http://curl.haxx.se/bug/view.cgi?id=3154436
Reported by: "dperham"

lib/connect.c

index 604bb2a1a55aa921fd206af748d6320a633ddac8..bcc1ed74ab841b11fa47e0530cf205ad004847a3 100644 (file)
@@ -857,7 +857,7 @@ singleipconnect(struct connectdata *conn,
 
   addr.family = ai->ai_family;
   addr.socktype = conn->socktype;
-  addr.protocol = ai->ai_protocol;
+  addr.protocol = conn->socktype==SOCK_DGRAM?IPPROTO_UDP:ai->ai_protocol;
   addr.addrlen = ai->ai_addrlen;
 
   if(addr.addrlen > sizeof(struct Curl_sockaddr_storage))