Fix off-by-one error in the check for s against FD_SETSIZE in add_socketread()

and set_socketwrite().  This was found by Coverity.



git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@237 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Kevin Easton
2013-06-16 06:04:29 +00:00
parent 6045b8fe91
commit bad477f9dc
2 changed files with 5 additions and 2 deletions

View File

@@ -1,5 +1,8 @@
[Changes 1.2c01] [Changes 1.2c01]
* Fix off-by-one error in add_socketread() and set_socketwrite() found
by Coverity. (caf)
* Fix longstanding bug with ordering of rfc1459[] array. (caf) * Fix longstanding bug with ordering of rfc1459[] array. (caf)
* Fix crash after /SETAR -, reported by riderplus. (caf) * Fix crash after /SETAR -, reported by riderplus. (caf)

View File

@@ -3513,7 +3513,7 @@ int BX_add_socketread(int s, int port, unsigned long flags, char *server, void (
FD_ZERO(&rd); FD_ZERO(&rd);
set_socket_read(&rd, &rd); set_socket_read(&rd, &rd);
} }
if (s > FD_SETSIZE) if (s >= FD_SETSIZE)
return -1; return -1;
if (s > sock_manager.max_fd) if (s > sock_manager.max_fd)
sock_manager.max_fd = s; sock_manager.max_fd = s;
@@ -3531,7 +3531,7 @@ int BX_add_socketread(int s, int port, unsigned long flags, char *server, void (
int BX_set_socketwrite(int s) int BX_set_socketwrite(int s)
{ {
if (s > FD_SETSIZE) if (s >= FD_SETSIZE)
return -1; return -1;
if (s > sock_manager.max_fd) if (s > sock_manager.max_fd)
sock_manager.max_fd = s; sock_manager.max_fd = s;