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
Родитель ebc2198d9f
Коммит 90b9900dc1
1 изменённых файлов: 1 добавлений и 1 удалений

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