[project @ 2005-11-30 15:58:47 by simonmar]
authorsimonmar <unknown>
Wed, 30 Nov 2005 15:58:47 +0000 (15:58 +0000)
committersimonmar <unknown>
Wed, 30 Nov 2005 15:58:47 +0000 (15:58 +0000)
check for overrun of the fd_set, some OSs give you more descriptors
than FD_SETSIZE

ghc/rts/posix/Select.c

index 8dfafe2..0f7a6df 100644 (file)
@@ -144,6 +144,9 @@ awaitEvent(rtsBool wait)
        case BlockedOnRead:
          { 
            int fd = tso->block_info.fd;
+           if (fd >= FD_SETSIZE) {
+               barf("awaitEvent: descriptor out of range");
+           }
            maxfd = (fd > maxfd) ? fd : maxfd;
            FD_SET(fd, &rfd);
            continue;
@@ -152,6 +155,9 @@ awaitEvent(rtsBool wait)
        case BlockedOnWrite:
          { 
            int fd = tso->block_info.fd;
+           if (fd >= FD_SETSIZE) {
+               barf("awaitEvent: descriptor out of range");
+           }
            maxfd = (fd > maxfd) ? fd : maxfd;
            FD_SET(fd, &wfd);
            continue;