summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYusuke Endoh <mame@ruby-lang.org>2019-10-13 00:49:18 +0900
committerYusuke Endoh <mame@ruby-lang.org>2019-10-13 00:49:18 +0900
commit90b9900dc159efb63feee9b0995cc5d56aef6d75 (patch)
tree231a9103970e83b969b4ac135a5acfb83e62b27f
parentebc2198d9f0292fee97e623b5e2a545fccb91d2a (diff)
io.c (rb_update_max_fd): fail with a negative file descripter
Coverity Scan points out that ext/socket/unixsocket.c may pass -1 to rb_update_max_fd. I'm unsure whether it can happen actually or not, but it would be good for the function to reject a negative value.
-rw-r--r--io.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/io.c b/io.c
index 33350ea..eccd429 100644
--- a/io.c
+++ b/io.c
@@ -201,7 +201,7 @@ rb_update_max_fd(int fd)
rb_atomic_t max_fd = max_file_descriptor;
int err;
- if (afd <= max_fd)
+ if (fd < 0 || afd <= max_fd)
return;
#if defined(HAVE_FCNTL) && defined(F_GETFL)