cURL / Mailing Lists / curl-library / Single Mail

curl-library

Access Violation!

From: Yanick Pelletier <ypelletier_at_copernic.com>
Date: Thu, 1 Nov 2001 14:04:09 -0500

First of all i use libcurl v7.9.1
 
When i download some HTTP documents, some time an access violation occur in
the following function. It happen that the Curl_connecthost() function
return add with a value of 0. In this case the call to memcpy fail!
 
        static CURLcode ConnectPlease(struct connectdata *conn)
        {
            CURLcode result;
            Curl_ipconnect *addr;
 
            /*************************************************************
            * Connect to server/proxy
            *************************************************************/
            result= Curl_connecthost(conn,
                                                 conn->hostaddr,
                                                 conn->port,
                                                 &conn->firstsocket,
                                                 &addr);
            if(CURLE_OK == result) {
                /* All is cool, then we store the current information from
the hostaddr
                   struct to the serv_addr, as it might be needed later. The
address
                   returned from the function above is crucial here. */
                memset((char *) &conn->serv_addr, '\0',
sizeof(conn->serv_addr));
                memcpy((char *)&(conn->serv_addr.sin_addr),
                             (struct in_addr *)addr, sizeof(struct
in_addr));
                conn->serv_addr.sin_family = conn->hostaddr->h_addrtype;
                conn->serv_addr.sin_port = htons(conn->port);
            }
            return result;
        }

Does it is normal that Curl_connecthost() doesn't return an error in such
case?
Maybe we can add a check case in the function to check such case like:
 
        if (addr == 0)
            return CURLE_COULDNT_CONNECT;
 
 
Thanks!
 
Yanick
 
Received on 2001-11-01