[前][次][番号順一覧][スレッド一覧]

ruby-changes:58227

From: Yusuke <ko1@a...>
Date: Sun, 13 Oct 2019 00:54:04 +0900 (JST)
Subject: [ruby-changes:58227] 90b9900dc1 (master): io.c (rb_update_max_fd): fail with a negative file descripter

https://git.ruby-lang.org/ruby.git/commit/?id=90b9900dc1

From 90b9900dc159efb63feee9b0995cc5d56aef6d75 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Sun, 13 Oct 2019 00:49:18 +0900
Subject: 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.

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) https://github.com/ruby/ruby/blob/trunk/io.c#L201
     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)
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]