1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.
This commit is contained in:
Yusuke Endoh 2019-10-13 00:49:18 +09:00
parent ebc2198d9f
commit 90b9900dc1

2
io.c
View file

@ -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)