This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Hi, attached there is a patch to add some validation for parameters of _hurd_select(). Thanks, -- Pino Toscano
_hurd_select: check for invalid parameter values
Check for invalid values of the `timeout' and `nfds' parameters; move the
calculation of `to' right after the validation of `timeout'.
2011-11-26 Pino Toscano <toscano.pino@tiscali.it>
* hurd/hurdselect.c (_hurd_select): Return EINVAL for negative
`timeout' values.
Return EINVAL for `nfds' values either negative or greater than
FD_SETSIZE.
--- a/hurd/hurdselect.c
+++ b/hurd/hurdselect.c
@@ -50,10 +50,7 @@ _hurd_select (int nfds,
error_t err;
fd_set rfds, wfds, xfds;
int firstfd, lastfd;
- mach_msg_timeout_t to = (timeout != NULL ?
- (timeout->tv_sec * 1000 +
- (timeout->tv_nsec + 999999) / 1000000) :
- 0);
+ mach_msg_timeout_t to = 0;
struct
{
struct hurd_userlink ulink;
@@ -72,6 +69,24 @@ _hurd_select (int nfds,
assert (sizeof (union typeword) == sizeof (mach_msg_type_t));
assert (sizeof (uint32_t) == sizeof (mach_msg_type_t));
+ if (nfds < 0 || nfds > FD_SETSIZE)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (timeout != NULL)
+ {
+ if (timeout->tv_sec < 0 || timeout->tv_nsec < 0)
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ to = timeout->tv_sec * 1000 +
+ (timeout->tv_nsec + 999999) / 1000000;
+ }
+
if (sigmask && __sigprocmask (SIG_SETMASK, sigmask, &oset))
return -1;
Attachment:
signature.asc
Description: This is a digitally signed message part.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |