for (;;) {
FD_ZERO(&waitread);
FD_SET(0, &waitread);
- n = select(8*sizeof(waitread), &waitread, 0, 0, 0, 0);
+ n = select(1, &waitread, 0, 0, 0, 0);
if (n < 0 && errno == EINTR)
continue;
if (n > 0)
}
}
- if (select(8*sizeof(ibits), &ibits, &obits, &ebits, 0) < 0) {
+ if (select(((p > f) ? p : f) + 1, &ibits, &obits, &ebits, 0) < 0) {
if (errno == EINTR)
continue;
fatalperror(f, "select");
rewrite:
FD_ZERO(&rembits);
FD_SET(rem, &rembits);
- if (select(8*sizeof(rembits), 0, &rembits, 0, 0) < 0) {
+ if (select(rem + 1, 0, &rembits, 0, 0) < 0) {
if (errno != EINTR) {
perror("select");
exit(1);
FD_SET(rem, &readfrom);
do {
ready = readfrom;
- if (select(8*sizeof(ready), &ready, 0, 0, 0) < 0) {
+ if (select(((rfd2 > rem) ? rfd2 : rem) + 1, &ready, 0, 0, 0) < 0) {
if (errno != EINTR) {
perror("select");
exit(1);
fd = 0;
}
+/*
+ * AIX passes an IPv4-mapped IPv6 address back from getpeername, but if
+ * that address is later used in connect(), it returns an error. Convert
+ * IPv4-mapped IPv6 addresses to simple IPv4 addresses on AIX (but don't
+ * do this everywhere since it isn't always the right thing to do, just
+ * the least wrong on AIX).
+ */
+#if defined(_AIX) && defined(KRB5_USE_INET6)
+ if (((struct sockaddr*)&from)->sa_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&sa2sin6(&from)->sin6_addr)) {
+ sa2sin(&from)->sin_len = sizeof(struct sockaddr_in);
+ sa2sin(&from)->sin_family = AF_INET;
+ sa2sin(&from)->sin_port = sa2sin6(&from)->sin6_port;
+ memmove(&(sa2sin(&from)->sin_addr.s_addr), &(sa2sin6(&from)->sin6_addr.u6_addr.u6_addr8[12]), 4);
+ }
+#endif
+
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&on,
sizeof (on)) < 0)
syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m");
goto signout_please;
}
if (pid) {
+ int maxfd;
#ifdef POSIX_SIGNALS
sa.sa_handler = cleanup;
(void)sigaction(SIGINT, &sa, (struct sigaction *)0);
FD_ZERO(&readfrom);
FD_SET(f, &readfrom);
+ maxfd = f;
if(port) {
FD_SET(s, &readfrom);
+ if (s > maxfd)
+ maxfd = s;
FD_SET(pv[0], &readfrom);
+ if (pv[0] > maxfd)
+ maxfd = pv[0];
}
FD_SET(pw[0], &readfrom);
+ if (pw[0] > maxfd)
+ maxfd = pw[0];
/* read from f, write to px[1] -- child stdin */
/* read from s, signal child */
do {
ready = readfrom;
- if (select(8*sizeof(ready), &ready, (fd_set *)0,
+ if (select(maxfd + 1, &ready, (fd_set *)0,
(fd_set *)0, (struct timeval *)0) < 0) {
if (errno == EINTR) {
continue;