summaryrefslogtreecommitdiffstats
path: root/source/winbindd
diff options
context:
space:
mode:
Diffstat (limited to 'source/winbindd')
-rw-r--r--source/winbindd/winbindd.c12
-rw-r--r--source/winbindd/winbindd_dual.c7
2 files changed, 18 insertions, 1 deletions
diff --git a/source/winbindd/winbindd.c b/source/winbindd/winbindd.c
index 1d618e26317..6b5c251bf6b 100644
--- a/source/winbindd/winbindd.c
+++ b/source/winbindd/winbindd.c
@@ -836,7 +836,8 @@ static void process_loop(void)
listen_sock = open_winbindd_socket();
listen_priv_sock = open_winbindd_priv_socket();
- if (listen_sock == -1 || listen_priv_sock == -1) {
+ if (listen_sock < 0 || listen_sock >= FD_SETSIZE ||
+ listen_priv_sock < 0 || listen_priv_sock >= FD_SETSIZE) {
perror("open_winbind_socket");
exit(1);
}
@@ -861,6 +862,9 @@ static void process_loop(void)
FD_ZERO(&r_fds);
FD_ZERO(&w_fds);
+
+ /* We check the range for listen_sock and
+ listen_priv_sock above. */
FD_SET(listen_sock, &r_fds);
FD_SET(listen_priv_sock, &r_fds);
@@ -890,6 +894,12 @@ static void process_loop(void)
}
for (ev = fd_events; ev; ev = ev->next) {
+ if (ev->fd < 0 || ev->fd >= FD_SETSIZE) {
+ /* Ignore here - event_add_to_select_args
+ should make this impossible. */
+ continue;
+ }
+
if (ev->flags & EVENT_FD_READ) {
FD_SET(ev->fd, &r_fds);
maxfd = MAX(ev->fd, maxfd);
diff --git a/source/winbindd/winbindd_dual.c b/source/winbindd/winbindd_dual.c
index ff004f293ce..b30ec20b4a1 100644
--- a/source/winbindd/winbindd_dual.c
+++ b/source/winbindd/winbindd_dual.c
@@ -1250,6 +1250,12 @@ static bool fork_domain_child(struct winbindd_child *child)
return False;
}
+ if (fdpair[0] < 0 || fdpair[0] >= FD_SETSIZE) {
+ DEBUG(0, ("fork_domain_child: bad fd range (%d)\n", fdpair[0]));
+ errno = EBADF;
+ return False;
+ }
+
ZERO_STRUCT(state);
state.pid = sys_getpid();
@@ -1405,6 +1411,7 @@ static bool fork_domain_child(struct winbindd_child *child)
message_dispatch(winbind_messaging_context());
FD_ZERO(&read_fds);
+ /* We check state.sock against FD_SETSIZE above. */
FD_SET(state.sock, &read_fds);
ret = sys_select(state.sock + 1, &read_fds, NULL, NULL, tp);