Commit cc619639 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

winhttp: Change type of netconn_resolve from struct sockaddr_in * to struct sockaddr *.

parent c2ef4e79
...@@ -566,7 +566,7 @@ DWORD netconn_set_timeout( netconn_t *netconn, BOOL send, int value ) ...@@ -566,7 +566,7 @@ DWORD netconn_set_timeout( netconn_t *netconn, BOOL send, int value )
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
BOOL netconn_resolve( WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr_in *sa ) BOOL netconn_resolve( WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr *sa, socklen_t *sa_len )
{ {
char *hostname; char *hostname;
#ifdef HAVE_GETADDRINFO #ifdef HAVE_GETADDRINFO
...@@ -574,6 +574,7 @@ BOOL netconn_resolve( WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr_in * ...@@ -574,6 +574,7 @@ BOOL netconn_resolve( WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr_in *
int ret; int ret;
#else #else
struct hostent *he; struct hostent *he;
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
#endif #endif
if (!(hostname = strdupWA( hostnameW ))) return FALSE; if (!(hostname = strdupWA( hostnameW ))) return FALSE;
...@@ -589,10 +590,17 @@ BOOL netconn_resolve( WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr_in * ...@@ -589,10 +590,17 @@ BOOL netconn_resolve( WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr_in *
TRACE("failed to get address of %s (%s)\n", debugstr_w(hostnameW), gai_strerror(ret)); TRACE("failed to get address of %s (%s)\n", debugstr_w(hostnameW), gai_strerror(ret));
return FALSE; return FALSE;
} }
if (*sa_len < sizeof(struct sockaddr_in))
{
WARN("address too small\n");
freeaddrinfo( res );
return FALSE;
}
*sa_len = sizeof(struct sockaddr_in);
memset( sa, 0, sizeof(struct sockaddr_in) ); memset( sa, 0, sizeof(struct sockaddr_in) );
memcpy( &sa->sin_addr, &((struct sockaddr_in *)res->ai_addr)->sin_addr, sizeof(struct in_addr) ); memcpy( &((struct sockaddr_in *)sa)->sin_addr, &((struct sockaddr_in *)res->ai_addr)->sin_addr, sizeof(struct in_addr) );
sa->sin_family = res->ai_family; ((struct sockaddr_in *)sa)->sin_family = res->ai_family;
sa->sin_port = htons( port ); ((struct sockaddr_in *)sa)->sin_port = htons( port );
freeaddrinfo( res ); freeaddrinfo( res );
#else #else
...@@ -606,10 +614,17 @@ BOOL netconn_resolve( WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr_in * ...@@ -606,10 +614,17 @@ BOOL netconn_resolve( WCHAR *hostnameW, INTERNET_PORT port, struct sockaddr_in *
LeaveCriticalSection( &cs_gethostbyname ); LeaveCriticalSection( &cs_gethostbyname );
return FALSE; return FALSE;
} }
if (*sa_len < sizeof(struct sockaddr_in))
{
WARN("address too small\n");
LeaveCriticalSection( &cs_gethostbyname );
return FALSE;
}
*sa_len = sizeof(struct sockaddr_in);
memset( sa, 0, sizeof(struct sockaddr_in) ); memset( sa, 0, sizeof(struct sockaddr_in) );
memcpy( &sa->sin_addr, he->h_addr, he->h_length ); memcpy( &sin->sin_addr, he->h_addr, he->h_length );
sa->sin_family = he->h_addrtype; sin->sin_family = he->h_addrtype;
sa->sin_port = htons( port ); sin->sin_port = htons( port );
LeaveCriticalSection( &cs_gethostbyname ); LeaveCriticalSection( &cs_gethostbyname );
#endif #endif
......
...@@ -716,6 +716,7 @@ static BOOL open_connection( request_t *request ) ...@@ -716,6 +716,7 @@ static BOOL open_connection( request_t *request )
char address[32]; char address[32];
WCHAR *addressW; WCHAR *addressW;
INTERNET_PORT port; INTERNET_PORT port;
socklen_t slen;
if (netconn_connected( &request->netconn )) return TRUE; if (netconn_connected( &request->netconn )) return TRUE;
...@@ -724,7 +725,8 @@ static BOOL open_connection( request_t *request ) ...@@ -724,7 +725,8 @@ static BOOL open_connection( request_t *request )
send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, connect->servername, strlenW(connect->servername) + 1 ); send_callback( &request->hdr, WINHTTP_CALLBACK_STATUS_RESOLVING_NAME, connect->servername, strlenW(connect->servername) + 1 );
if (!netconn_resolve( connect->servername, port, &connect->sockaddr )) return FALSE; slen = sizeof(connect->sockaddr);
if (!netconn_resolve( connect->servername, port, (struct sockaddr *)&connect->sockaddr, &slen )) return FALSE;
inet_ntop( connect->sockaddr.sin_family, &connect->sockaddr.sin_addr, address, sizeof(address) ); inet_ntop( connect->sockaddr.sin_family, &connect->sockaddr.sin_addr, address, sizeof(address) );
addressW = strdupAW( address ); addressW = strdupAW( address );
......
...@@ -211,7 +211,7 @@ BOOL netconn_get_next_line( netconn_t *, char *, DWORD * ); ...@@ -211,7 +211,7 @@ BOOL netconn_get_next_line( netconn_t *, char *, DWORD * );
BOOL netconn_init( netconn_t *, BOOL ); BOOL netconn_init( netconn_t *, BOOL );
BOOL netconn_query_data_available( netconn_t *, DWORD * ); BOOL netconn_query_data_available( netconn_t *, DWORD * );
BOOL netconn_recv( netconn_t *, void *, size_t, int, int * ); BOOL netconn_recv( netconn_t *, void *, size_t, int, int * );
BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_in * ); BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr *, socklen_t * );
BOOL netconn_secure_connect( netconn_t * ); BOOL netconn_secure_connect( netconn_t * );
BOOL netconn_send( netconn_t *, const void *, size_t, int, int * ); BOOL netconn_send( netconn_t *, const void *, size_t, int, int * );
DWORD netconn_set_timeout( netconn_t *, BOOL, int ); DWORD netconn_set_timeout( netconn_t *, BOOL, int );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment