diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2012-02-16 10:28:53 +0900 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-02-16 10:28:53 +0900 |
commit | 9ba5373f788958b61588203add314b8a9a5c4618 (patch) | |
tree | 55cbc96ed12ddf1b64d9674b53b85f168a151133 /src/upoll.cpp | |
parent | a0d548e6cdef36a8dae6e6834252475728bf8583 (diff) |
Avoid too long timeouts in xs_poll
The timeout should be int. For historical reasons, however,
it is defined as long. To fix the problem the value is
checked in the runtime to assure it is not larger than INT_MAX.
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/upoll.cpp')
-rw-r--r-- | src/upoll.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/upoll.cpp b/src/upoll.cpp index c4aa0a1..592cc42 100644 --- a/src/upoll.cpp +++ b/src/upoll.cpp @@ -56,10 +56,12 @@ #include <unistd.h> #endif +#include <limits.h> + int xs::upoll (xs_pollitem_t *items_, int nitems_, long timeout_) { #if defined XS_POLL_BASED_ON_POLL - if (unlikely (nitems_ < 0)) { + if (unlikely (nitems_ < 0 || timeout_ > INT_MAX)) { errno = EINVAL; return -1; } |