From bad477f9dcd0c7efeacc452907d2c58c67dd0cba Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Sun, 16 Jun 2013 06:04:29 +0000 Subject: [PATCH] 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 --- Changelog | 3 +++ source/misc.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 87afc93..6bacf4a 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,8 @@ [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 crash after /SETAR -, reported by riderplus. (caf) diff --git a/source/misc.c b/source/misc.c index 81e2a08..5ad8f9a 100644 --- a/source/misc.c +++ b/source/misc.c @@ -3513,7 +3513,7 @@ int BX_add_socketread(int s, int port, unsigned long flags, char *server, void ( FD_ZERO(&rd); set_socket_read(&rd, &rd); } - if (s > FD_SETSIZE) + if (s >= FD_SETSIZE) return -1; if (s > sock_manager.max_fd) 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) { - if (s > FD_SETSIZE) + if (s >= FD_SETSIZE) return -1; if (s > sock_manager.max_fd) sock_manager.max_fd = s;