From 90b9900dc159efb63feee9b0995cc5d56aef6d75 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Sun, 13 Oct 2019 00:49:18 +0900 Subject: [PATCH] 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. --- io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io.c b/io.c index 33350ea752..eccd429352 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)