aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-10-22 12:52:25 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-10-22 12:52:25 +0000
commitb585f411cde3419af383bd270aa801cdb8dc6e5c (patch)
treedf7ec11ea6bf12afd77fb4b306d4d85b023ad9e1
parent5ccd6bb8429b5ab2776409d3b18fe8d2860e2ea7 (diff)
make sure the connect can't return OK but return a NULL as addr
-rw-r--r--lib/connect.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/connect.c b/lib/connect.c
index df34d7edc..4adc9f85c 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -340,7 +340,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
{
struct SessionHandle *data = conn->data;
int rc;
- int sockfd;
+ int sockfd=-1;
int aliasindex=0;
struct timeval after;
@@ -459,11 +459,18 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
/*
* Connecting with IPv4-only support
*/
-
+ if(!remotehost->h_addr_list[0]) {
+ /* If there is no addresses in the address list, then we return
+ error right away */
+ failf(data, "no address available");
+ return CURLE_COULDNT_CONNECT;
+ }
/* create an IPv4 TCP socket */
sockfd = socket(AF_INET, SOCK_STREAM, 0);
- if(-1 == sockfd)
+ if(-1 == sockfd) {
+ failf(data, "couldn't create socket");
return CURLE_COULDNT_CONNECT; /* big time error */
+ }
if(conn->data->set.device) {
/* user selected to bind the outgoing socket to a specified "device"