[1160] in Kerberos-V5-bugs
krb5b4pl3: appl/bsd/krlogind.c: should use select() types and macros, not int bitmasks
daemon@ATHENA.MIT.EDU (Jonathan I. Kamens)
Tue Mar 14 11:12:12 1995
From: "Jonathan I. Kamens" <jik@cam.ov.com>
Date: Tue, 14 Mar 1995 11:15:03 -0500
To: krb5-bugs@MIT.EDU
--- appl/bsd/krlogind.c 1995/03/09 21:54:51 1.4
+++ appl/bsd/krlogind.c 1995/03/14 00:31:50 1.5.1.2
@@ -101,6 +101,7 @@
#define CRYPT
#include <stdio.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
@@ -907,43 +908,40 @@
send(f, oobdata, 1, MSG_OOB); /* indicate new rlogin */
#endif
for (;;) {
- int ibits, obits, ebits;
+ fd_set ibits, obits, ebits;
+
+ FD_ZERO(&ibits);
+ FD_ZERO(&obits);
+ FD_ZERO(&ebits);
- ibits = 0;
- obits = 0;
if (fcc)
- obits |= (1<<p);
+ FD_SET(p, &obits);
else
- ibits |= (1<<f);
+ FD_SET(f, &ibits);
if (pcc >= 0)
if (pcc)
- obits |= (1<<f);
+ FD_SET(f, &obits);
else
- ibits |= (1<<p);
- ebits = (1<<p);
+ FD_SET(p, &ibits);
+ FD_SET(p, &ebits);
if (select(16, &ibits, &obits, &ebits, 0) < 0) {
if (errno == EINTR)
continue;
fatalperror(f, "select");
}
- if (ibits == 0 && obits == 0 && ebits == 0) {
- /* shouldn't happen... */
- sleep(5);
- continue;
- }
#define pkcontrol(c) ((c)&(TIOCPKT_FLUSHWRITE|TIOCPKT_NOSTOP|TIOCPKT_DOSTOP))
- if (ebits & (1<<p)) {
+ if (FD_ISSET(p, &ebits)) {
cc = read(p, &cntl, 1);
if (cc == 1 && pkcontrol(cntl)) {
cntl |= oobdata[0];
send(f, &cntl, 1, MSG_OOB);
if (cntl & TIOCPKT_FLUSHWRITE) {
pcc = 0;
- ibits &= ~(1<<p);
+ FD_CLR(p, &ibits);
}
}
}
- if (ibits & (1<<f)) {
+ if (FD_ISSET(f, &ibits)) {
fcc = (*des_read)(f, fibuf, sizeof (fibuf));
if (fcc < 0 && errno == EWOULDBLOCK)
fcc = 0;
@@ -974,7 +972,7 @@
}
}
- if ((obits & (1<<p)) && fcc > 0) {
+ if (FD_ISSET(p, &obits) && fcc > 0) {
cc = write(p, fbp, fcc);
if (cc > 0) {
fcc -= cc;
@@ -982,7 +980,7 @@
}
}
- if (ibits & (1<<p)) {
+ if (FD_ISSET(p, &ibits)) {
pcc = read(p, pibuf, sizeof (pibuf));
pbp = pibuf;
if (pcc < 0 && errno == EWOULDBLOCK)
@@ -999,7 +997,7 @@
pcc = 0;
}
}
- if ((obits & (1<<f)) && pcc > 0) {
+ if (FD_ISSET(f, &obits) && pcc > 0) {
cc = (*des_write)(f, pbp, pcc);
if (cc < 0 && errno == EWOULDBLOCK) {
/* also shouldn't happen */