update release notes
[openssl.git] / apps / s_socket.c
index c08544a13cbb5413f6eefd8718f3def000c38f5b..94eb40f3ffc8777eaf87b036b4b723da95a94322 100644 (file)
@@ -238,11 +238,10 @@ int init_client(int *sock, char *host, int port, int type)
        {
        unsigned char ip[4];
 
+       memset(ip, '\0', sizeof ip);
        if (!host_ip(host,&(ip[0])))
-               {
-               return(0);
-               }
-       return(init_client_ip(sock,ip,port,type));
+               return 0;
+       return init_client_ip(sock,ip,port,type);
        }
 
 static int init_client_ip(int *sock, unsigned char ip[4], int port, int type)
@@ -275,7 +274,7 @@ static int init_client_ip(int *sock, unsigned char ip[4], int port, int type)
                {
                i=0;
                i=setsockopt(s,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
-               if (i < 0) { perror("keepalive"); return(0); }
+               if (i < 0) { closesocket(s); perror("keepalive"); return(0); }
                }
 #endif
 
@@ -451,6 +450,7 @@ redoit:
                if ((*host=(char *)OPENSSL_malloc(strlen(h1->h_name)+1)) == NULL)
                        {
                        perror("OPENSSL_malloc");
+                       closesocket(ret);
                        return(0);
                        }
                BUF_strlcpy(*host,h1->h_name,strlen(h1->h_name)+1);
@@ -459,11 +459,13 @@ redoit:
                if (h2 == NULL)
                        {
                        BIO_printf(bio_err,"gethostbyname failure\n");
+                       closesocket(ret);
                        return(0);
                        }
                if (h2->h_addrtype != AF_INET)
                        {
                        BIO_printf(bio_err,"gethostbyname addr is not AF_INET\n");
+                       closesocket(ret);
                        return(0);
                        }
                }