mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
check if getsockname() returns failure before using the address it provides
This commit is contained in:
parent
723aef71e8
commit
ede9fb4fcc
@ -209,11 +209,11 @@ static CURLcode AllowServerConnect(struct connectdata *conn)
|
|||||||
default:
|
default:
|
||||||
/* we have received data here */
|
/* we have received data here */
|
||||||
{
|
{
|
||||||
curl_socket_t s;
|
curl_socket_t s = CURL_SOCKET_BAD;
|
||||||
socklen_t size = (socklen_t) sizeof(struct sockaddr_in);
|
socklen_t size = (socklen_t) sizeof(struct sockaddr_in);
|
||||||
struct sockaddr_in add;
|
struct sockaddr_in add;
|
||||||
|
|
||||||
getsockname(sock, (struct sockaddr *) &add, &size);
|
if(0 == getsockname(sock, (struct sockaddr *) &add, &size))
|
||||||
s=accept(sock, (struct sockaddr *) &add, &size);
|
s=accept(sock, (struct sockaddr *) &add, &size);
|
||||||
|
|
||||||
sclose(sock); /* close the first socket */
|
sclose(sock); /* close the first socket */
|
||||||
|
Loading…
Reference in New Issue
Block a user