Dont allow a tcp _connect to a UDP context
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Sun, 26 Jun 2011 08:32:06 +0000 (18:32 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Sun, 26 Jun 2011 08:32:06 +0000 (18:32 +1000)
lib/socket.c

index ffccd27f39249b44980de36df901579a605c6cc6..a0ededa61a625f7cc463b1a2d4da8cca78dcf1de 100644 (file)
@@ -287,6 +287,11 @@ int rpc_connect_async(struct rpc_context *rpc, const char *server, int port, rpc
                return -1;
        }
 
+       if (rpc->is_udp != 0) {
+               rpc_set_error(rpc, "Trying to connect on UDP socket");
+               return -1;
+       }
+
        sin->sin_family = AF_INET;
        sin->sin_port   = htons(port);
        if (inet_pton(AF_INET, server, &sin->sin_addr) != 1) {