From: Daniel Stenberg Date: Mon, 18 Apr 2005 08:49:46 +0000 (+0000) Subject: safety measure to avoid using -1 as socket X-Git-Tag: curl-7_14_0~155 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b62baaed959e52c9dc442c73cb85e2bb0d4d97a9;p=thirdparty%2Fcurl.git safety measure to avoid using -1 as socket --- diff --git a/tests/server/sockfilt.c b/tests/server/sockfilt.c index 07c81b11d0..5cbf045e73 100644 --- a/tests/server/sockfilt.c +++ b/tests/server/sockfilt.c @@ -288,10 +288,17 @@ static int juggle(curl_socket_t *sockfdp, case PASSIVE_CONNECT: sockfd = *sockfdp; - logmsg("waiting for data from client on socket %d", (int)sockfd); - /* there's always a socket to wait for */ - FD_SET(sockfd, &fds_read); - maxfd = sockfd; + if(-1 == sockfd) { + /* eeek, we are supposedly connected and then this cannot be -1 ! */ + logmsg("socket is -1! on %s:%d", __FILE__, __LINE__); + return FALSE; + } + else { + logmsg("waiting for data from client on socket %d", (int)sockfd); + /* there's always a socket to wait for */ + FD_SET(sockfd, &fds_read); + maxfd = sockfd; + } break; case ACTIVE: