struct connection *newconn;
void *tmp;
+ if (sock > FD_SETSIZE) {
+ data->retval = EMFILE; /* XXX */
+ com_err(data->prog, 0,
+ "file descriptor number %d too high", sock);
+ return 0;
+ }
newconn = malloc(sizeof(*newconn));
if (newconn == 0) {
data->retval = errno;
paddr(addr));
return -1;
}
+ if (sock > FD_SETSIZE) {
+ close(sock);
+ com_err(data->prog, 0, "TCP socket fd number %d (for %s) too high",
+ sock, paddr(addr));
+ return -1;
+ }
if (setreuseaddr(sock, 1) < 0)
com_err(data->prog, errno,
"Cannot enable SO_REUSEADDR on fd %d", sock);
s = accept(conn->fd, addr, &addrlen);
if (s < 0)
return;
+ if (s > FD_SETSIZE) {
+ close(s);
+ return;
+ }
setnbio(s), setnolinger(s);
sockdata.prog = prog;
dprint("socket: %m creating with af %d\n", state->err, ai->ai_family);
return -1; /* try other hosts */
}
+ if (fd > FD_SETSIZE) {
+ close(fd);
+ state->err = EMFILE;
+ dprint("socket: fd %d too high\n", fd);
+ return -1;
+ }
/* Make it non-blocking. */
if (ai->ai_socktype == SOCK_STREAM) {
static const int one = 1;