[commit: ghc] master: reading/writing blocking FDs over FD_SETSIZE is broken (Partially Trac #9169) (b0316cd)
git at git.haskell.org
git at git.haskell.org
Wed Jul 2 15:12:09 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/b0316cdb10fbd9eaca7ede28c7bb3eb19f7766bf/ghc
>---------------------------------------------------------------
commit b0316cdb10fbd9eaca7ede28c7bb3eb19f7766bf
Author: Sergei Trofimovich <slyfox at gentoo.org>
Date: Wed Jul 2 08:53:34 2014 -0500
reading/writing blocking FDs over FD_SETSIZE is broken (Partially Trac #9169)
Summary:
libraries/base/cbits/inputReady.c had no limits on file descriptors.
Add a limit as non-threaded RTS does.
Signed-off-by: Sergei Trofimovich <slyfox at gentoo.org>
Test Plan: none
Reviewers: austin, simonmar
Reviewed By: austin, simonmar
Subscribers: simonmar, relrod, carter
Differential Revision: https://phabricator.haskell.org/D28
>---------------------------------------------------------------
b0316cdb10fbd9eaca7ede28c7bb3eb19f7766bf
libraries/base/cbits/inputReady.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libraries/base/cbits/inputReady.c b/libraries/base/cbits/inputReady.c
index 51f278f..dac9d9b 100644
--- a/libraries/base/cbits/inputReady.c
+++ b/libraries/base/cbits/inputReady.c
@@ -25,7 +25,11 @@ fdReady(int fd, int write, int msecs, int isSock)
int maxfd, ready;
fd_set rfd, wfd;
struct timeval tv;
-
+ if ((fd >= (int)FD_SETSIZE) || (fd < 0)) {
+ /* avoid memory corruption on too large FDs */
+ errno = EINVAL;
+ return -1;
+ }
FD_ZERO(&rfd);
FD_ZERO(&wfd);
if (write) {
More information about the ghc-commits
mailing list