diff options
Diffstat (limited to 'lib/pselect.c')
| -rw-r--r-- | lib/pselect.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/pselect.c b/lib/pselect.c index f5d21e1048a..1b8c19130c2 100644 --- a/lib/pselect.c +++ b/lib/pselect.c | |||
| @@ -45,6 +45,12 @@ pselect (int nfds, fd_set *restrict rfds, | |||
| 45 | sigset_t origmask; | 45 | sigset_t origmask; |
| 46 | struct timeval tv, *tvp; | 46 | struct timeval tv, *tvp; |
| 47 | 47 | ||
| 48 | if (nfds < 0 || nfds > FD_SETSIZE) | ||
| 49 | { | ||
| 50 | errno = EINVAL; | ||
| 51 | return -1; | ||
| 52 | } | ||
| 53 | |||
| 48 | if (timeout) | 54 | if (timeout) |
| 49 | { | 55 | { |
| 50 | if (! (0 <= timeout->tv_nsec && timeout->tv_nsec < 1000000000)) | 56 | if (! (0 <= timeout->tv_nsec && timeout->tv_nsec < 1000000000)) |
| @@ -53,8 +59,10 @@ pselect (int nfds, fd_set *restrict rfds, | |||
| 53 | return -1; | 59 | return -1; |
| 54 | } | 60 | } |
| 55 | 61 | ||
| 56 | tv.tv_sec = timeout->tv_sec; | 62 | tv = (struct timeval) { |
| 57 | tv.tv_usec = (timeout->tv_nsec + 999) / 1000; | 63 | .tv_sec = timeout->tv_sec, |
| 64 | .tv_usec = (timeout->tv_nsec + 999) / 1000 | ||
| 65 | }; | ||
| 58 | tvp = &tv; | 66 | tvp = &tv; |
| 59 | } | 67 | } |
| 60 | else | 68 | else |