diff options
author | brian <brian@FreeBSD.org> | 1997-05-10 01:22:19 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 1997-05-10 01:22:19 +0000 |
commit | 82bac13560d095243e9988bfb770da73089749c1 (patch) | |
tree | 262cfd051516c08f29f6f133a950e9de9f2d42fd /usr.sbin/ppp/main.c | |
parent | 1da867bda76bc701006945dfbc4733f550c91c2d (diff) | |
download | FreeBSD-src-82bac13560d095243e9988bfb770da73089749c1.zip FreeBSD-src-82bac13560d095243e9988bfb770da73089749c1.tar.gz |
Tidy up the code - bounds checking, return
value checking etc.
Submitted by: eivind
Diffstat (limited to 'usr.sbin/ppp/main.c')
-rw-r--r-- | usr.sbin/ppp/main.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 8c50561..755c449 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: main.c,v 1.45 1997/04/21 01:01:48 brian Exp $ + * $Id: main.c,v 1.46 1997/05/04 02:39:03 ache Exp $ * * TODO: * o Add commands for traffic summary, version display, etc. @@ -61,13 +61,12 @@ #endif extern void VjInit(), AsyncInit(); -extern void AsyncInput(), IpOutput(); +extern void AsyncInput(); extern int SelectSystem(); extern void DecodeCommand(), Prompt(); extern int aft_cmd; extern int IsInteractive(); -extern struct in_addr ifnetmask; static void DoLoop(void); static void TerminalStop(); @@ -87,8 +86,10 @@ TtyInit() int stat; stat = fcntl(0, F_GETFL, 0); - stat |= O_NONBLOCK; - fcntl(0, F_SETFL, stat); + if (stat > 0) { + stat |= O_NONBLOCK; + (void)fcntl(0, F_SETFL, stat); + } newtio = oldtio; newtio.c_lflag &= ~(ECHO|ISIG|ICANON); newtio.c_iflag = 0; @@ -120,10 +121,12 @@ int prompt; newtio.c_oflag |= OPOST; tcsetattr(0, TCSADRAIN, &newtio); stat = fcntl(0, F_GETFL, 0); - stat |= O_NONBLOCK; - fcntl(0, F_SETFL, stat); + if (stat > 0) { + stat |= O_NONBLOCK; + (void)fcntl(0, F_SETFL, stat); + } TermMode = 0; - if(prompt) Prompt(0); + if(prompt) Prompt(); } /* @@ -136,8 +139,10 @@ TtyTermMode() tcsetattr(0, TCSADRAIN, &comtio); stat = fcntl(0, F_GETFL, 0); - stat &= ~O_NONBLOCK; - fcntl(0, F_SETFL, stat); + if (stat > 0) { + stat &= ~O_NONBLOCK; + (void)fcntl(0, F_SETFL, stat); + } TermMode = 1; } @@ -147,8 +152,10 @@ TtyOldMode() int stat; stat = fcntl(0, F_GETFL, 0); - stat &= ~O_NONBLOCK; - fcntl(0, F_SETFL, stat); + if (stat > 0) { + stat &= ~O_NONBLOCK; + (void)fcntl(0, F_SETFL, stat); + } tcsetattr(0, TCSANOW, &oldtio); } @@ -390,12 +397,6 @@ char **argv; if (mode & MODE_DIRECT) printf("Packet mode enabled.\n"); -#ifdef notdef - if (mode & MODE_AUTO) { - OsSetIpaddress(IpcpInfo.want_ipaddr, IpcpInfo.his_ipaddr, ifnetmask); - } -#endif - if (!(mode & MODE_INTER)) { int port = SERVER_PORT + tunno; if (mode & MODE_BACKGROUND) { @@ -422,7 +423,9 @@ char **argv; fprintf(stderr, "Wait for a while, then try again.\n"); Cleanup(EX_SOCK); } - listen(server, 5); + if (listen(server, 5) != 0) { + fprintf(stderr, "Unable to listen to socket - OS overload?\n"); + } } DupLog(); @@ -927,7 +930,7 @@ DoLoop() break; } (void) IsInteractive(); - Prompt(0); + Prompt(); } if ((mode & MODE_INTER) && (netfd >= 0 && FD_ISSET(netfd, &rfds)) && @@ -963,18 +966,12 @@ DoLoop() write(1, "\r\n", 2); } PacketMode(); -#ifdef notdef - AsyncInput(cp, n - (cp - rbuff)); -#endif } else write(1, rbuff, n); } } else { if (n > 0) AsyncInput(rbuff, n); -#ifdef notdef - continue; /* THIS LINE RESULT AS POOR PERFORMANCE */ -#endif } } } |