aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2012-02-21 13:13:46 -0800
committerSam Roberts <vieuxtech@gmail.com>2012-04-11 13:54:01 -0700
commit0716cb868e847bb9f66c659f8662d905ba012de8 (patch)
treeba4df4697a66e1f0577930f3166331f696528ca8
parent27a3964ff7891a5f240ef08b3294714ef6e28074 (diff)
downloadluasocket-0716cb868e847bb9f66c659f8662d905ba012de8.tar.gz
luasocket-0716cb868e847bb9f66c659f8662d905ba012de8.tar.bz2
luasocket-0716cb868e847bb9f66c659f8662d905ba012de8.zip
Bounds check the argument to FD_SET
Failing to check the FD_SET argument against FD_SETSIZE causes undefined behaviour (segfaults, for example).
-rw-r--r--src/usocket.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/usocket.c b/src/usocket.c
index 3221cb9..f4c0a84 100644
--- a/src/usocket.c
+++ b/src/usocket.c
@@ -49,6 +49,7 @@ int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
49 fd_set rfds, wfds, *rp, *wp; 49 fd_set rfds, wfds, *rp, *wp;
50 struct timeval tv, *tp; 50 struct timeval tv, *tp;
51 double t; 51 double t;
52 if (*ps >= FD_SETSIZE) return EINVAL;
52 if (timeout_iszero(tm)) return IO_TIMEOUT; /* optimize timeout == 0 case */ 53 if (timeout_iszero(tm)) return IO_TIMEOUT; /* optimize timeout == 0 case */
53 do { 54 do {
54 /* must set bits within loop, because select may have modifed them */ 55 /* must set bits within loop, because select may have modifed them */