From b0cdb3ce11c88c81039eb3bb464d4355e928b04e Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Sat, 12 Oct 1996 16:20:34 +0000 Subject: [PATCH] 1. Room to calculate MD5 for CHAP negotiation is shorter than required. a core is not dumped at first connecting time and dumped at second or third time. (patch I) 2. A routine for "show route" refers out of allocated space. Values pointed by "lp" should be read as CHAR, I think. there is also no free() for disallocation. (patch II) Here is also a patch for an improvement: In current imprementation, even if PPP connection is disconnected by time out, prompt of interactive mode does not change from "PPP>" to "ppp>" to indicate the disconnection on a terminal. So I modified the code to do that. (patch III) Submitted-By: NAKAMURA Motonori --- usr.sbin/ppp/chap.c | 5 +++-- usr.sbin/ppp/command.c | 12 ++++++++---- usr.sbin/ppp/lcp.c | 9 ++++++++- usr.sbin/ppp/main.c | 6 +++++- usr.sbin/ppp/route.c | 10 ++++++---- 5 files changed, 30 insertions(+), 12 deletions(-) diff --git a/usr.sbin/ppp/chap.c b/usr.sbin/ppp/chap.c index 9b1937c4ba12..a3b1f80f2989 100644 --- a/usr.sbin/ppp/chap.c +++ b/usr.sbin/ppp/chap.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: chap.c,v 1.5 1996/01/30 11:08:25 dfr Exp $ + * $Id: chap.c,v 1.6 1996/05/11 20:48:16 phk Exp $ * * TODO: */ @@ -147,7 +147,7 @@ struct mbuf *bp; } name = VarAuthName; namelen = strlen(VarAuthName); - argp = malloc(1 + valsize + namelen); + argp = malloc(1 + valsize + namelen + 16); digest = argp; *digest++ = 16; /* value size */ ap = answer; @@ -169,6 +169,7 @@ struct mbuf *bp; ap += namelen; /* Send answer to the peer */ ChapOutput(CHAP_RESPONSE, chp->id, argp, namelen + 17); + free(argp); break; case CHAP_RESPONSE: if (keyp) { diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 67a45a1487a2..72e9a592ae52 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: command.c,v 1.21 1996/10/07 10:01:17 sos Exp $ + * $Id: command.c,v 1.22 1996/10/10 11:27:35 sos Exp $ * */ #include @@ -480,16 +480,20 @@ char **argv; return(val); } +int aft_cmd = 1; + void -Prompt(flag) -int flag; +Prompt() { char *pconnect, *pauth; if (!(mode & MODE_INTER)) return; - if (flag) printf("\n"); + if (!aft_cmd) + printf("\n"); + else + aft_cmd = 0; if ( VarLocalAuth == LOCAL_AUTH ) pauth = " ON "; diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c index bb465e69e0da..3e455539c288 100644 --- a/usr.sbin/ppp/lcp.c +++ b/usr.sbin/ppp/lcp.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: lcp.c,v 1.8 1996/01/30 11:08:35 dfr Exp $ + * $Id: lcp.c,v 1.9 1996/05/11 20:48:28 phk Exp $ * * TODO: * o Validate magic number received from peer. @@ -379,6 +379,7 @@ struct fsm *fp; StopAllTimers(); OsLinkdown(); NewPhase(PHASE_TERMINATE); + Prompt(1); } void @@ -663,6 +664,12 @@ reqreject: } break; } + /* to avoid inf. loop */ + if (length == 0) { + LogPrintf(LOG_LCP, "LCP size zero\n"); + break; + } + plen -= length; cp += length; } diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index 772be6cbb802..0c9a5cf4d5d9 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.20 1996/07/09 17:40:36 ache Exp $ + * $Id: main.c,v 1.21 1996/10/07 04:21:00 jkh Exp $ * * TODO: * o Add commands for traffic summary, version display, etc. @@ -61,6 +61,7 @@ extern void AsyncInput(), IpOutput(); extern int SelectSystem(); extern void DecodeCommand(), Prompt(); +extern int aft_cmd; extern int IsInteractive(); extern struct in_addr ifnetmask; static void DoLoop(void); @@ -455,6 +456,7 @@ PacketMode() if ((mode & (MODE_INTER|MODE_AUTO)) == MODE_INTER) { TtyCommandMode(1); fprintf(stderr, "Packet mode.\r\n"); + aft_cmd = 1; } } @@ -483,6 +485,7 @@ ReadTty() #endif if (!TermMode) { n = read(netfd, linebuff, sizeof(linebuff)-1); + aft_cmd = 1; if (n > 0) { DecodeCommand(linebuff, n, 1); } else { @@ -644,6 +647,7 @@ DoLoop() if (mode & MODE_DIRECT) { modem = OpenModem(mode); LogPrintf(LOG_PHASE_BIT, "Packet mode enabled\n"); + fflush(stderr); PacketMode(); } else if (mode & MODE_DEDICATED) { if (!modem) diff --git a/usr.sbin/ppp/route.c b/usr.sbin/ppp/route.c index b9570fa25e6c..9416836ae41a 100644 --- a/usr.sbin/ppp/route.c +++ b/usr.sbin/ppp/route.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: route.c,v 1.7 1996/08/13 09:19:45 peter Exp $ + * $Id: route.c,v 1.8 1996/10/06 13:32:35 jkh Exp $ * */ #include @@ -198,10 +198,12 @@ ShowRoute() #if (BSD >= 199306) if (sysctl(mib, 6, sp, &needed, NULL, 0) < 0) { perror("sysctl-getroute"); + free(sp); return(1); } #else if (getkerninfo(KINFO_RT_DUMP, sp, &needed, 0) < 0) + free(sp); return(1); #endif ep = sp + needed; @@ -226,11 +228,11 @@ ShowRoute() #endif wp = (u_char *)(lp + 1); mask = 0; - for (nb = *lp; nb > 4; nb--) { + for (nb = *(char *)lp; nb > 4; nb--) { mask <<= 8; mask |= *wp++; } - for (nb = 8 - *lp; nb > 0; nb--) + for (nb = 8 - *(char *)lp; nb > 0; nb--) mask <<= 8; } } @@ -238,7 +240,7 @@ ShowRoute() p_flags(rtm->rtm_flags & (RTF_UP|RTF_GATEWAY|RTF_HOST), "%-6.6s "); printf("(%d)\n", rtm->rtm_index); } - + free(sp); return(1); }