From: Daniel Stenberg Date: Tue, 17 May 2005 09:18:17 +0000 (+0000) Subject: check if getsockname() returns failure before using the address it provides X-Git-Tag: c-ares-1_3_0~176 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ede9fb4fcc600ae19d38a8b1b8833250e84801b7;p=curl check if getsockname() returns failure before using the address it provides --- diff --git a/lib/ftp.c b/lib/ftp.c index 740926a87..49a1d82d0 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -209,12 +209,12 @@ static CURLcode AllowServerConnect(struct connectdata *conn) default: /* 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); struct sockaddr_in add; - getsockname(sock, (struct sockaddr *) &add, &size); - s=accept(sock, (struct sockaddr *) &add, &size); + if(0 == getsockname(sock, (struct sockaddr *) &add, &size)) + s=accept(sock, (struct sockaddr *) &add, &size); sclose(sock); /* close the first socket */