From 84f4376c6c5236d0bd08d3ac9efff65b256290f3 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Thu, 31 Mar 2016 16:17:42 -0700 Subject: [PATCH] Don't allow the fd count to exceed FD_SETSIZE. --- src/core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/core.c b/src/core.c index 4f43f3c..596cc99 100755 --- a/src/core.c +++ b/src/core.c @@ -49,6 +49,10 @@ #include #include #ifdef HAVE_SYS_SELECT_H + +// You may need to override this! +// #define FD_SETSIZE 2048 + #include #endif #ifdef HAVE_KEVENT @@ -1076,6 +1080,15 @@ core_connect(Conn * s) goto failure; } + if (sd > FD_SETSIZE) { + fprintf(stderr, + "%s.core_connect.socket: sd > FD_SETSIZE (%d)\n", + prog_name, + FD_SETSIZE); + close(sd); + goto failure; + } + if (fcntl(sd, F_SETFL, O_NONBLOCK) < 0) { fprintf(stderr, "%s.core_connect.fcntl: %s\n", prog_name, strerror(errno));