diff options
author | ache <ache@FreeBSD.org> | 1996-04-06 02:00:17 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1996-04-06 02:00:17 +0000 |
commit | 6950a2d26ee1f9557197b09517773a2a4815f9c3 (patch) | |
tree | 62e9f27c062010bad1742822f069a06da2d8a0b9 /usr.sbin/ppp | |
parent | df817724e46921c40fc3cfb84b344b41ca53d250 (diff) | |
download | FreeBSD-src-6950a2d26ee1f9557197b09517773a2a4815f9c3.zip FreeBSD-src-6950a2d26ee1f9557197b09517773a2a4815f9c3.tar.gz |
Here is a patch for a little bug in the WaitForString routine. The problem
is when the matched string spans the end of the inbuff. This fix allocates
twice the IBSIZE so that it can keep the last and the current text to search
in the inbuff so that the match won't fail if it gets truncated by the read.
It also warns if the search string is to long and truncates it.
Submitted by: Dough Ambrisco <ambrisco@ambrisco.roble.com>
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/chat.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c index f31b441..e281f99 100644 --- a/usr.sbin/ppp/chat.c +++ b/usr.sbin/ppp/chat.c @@ -18,7 +18,7 @@ * Columbus, OH 43221 * (614)451-1883 * - * $Id: chat.c,v 1.7 1996/03/08 12:34:37 ache Exp $ + * $Id: chat.c,v 1.8 1996/03/08 13:22:21 ache Exp $ * * TODO: * o Support more UUCP compatible control sequences. @@ -45,7 +45,7 @@ static int TimeoutSec; static int abort_next, timeout_next; static int numaborts; char *AbortStrings[50]; -char inbuff[IBSIZE]; +char inbuff[IBSIZE*2+1]; extern int ChangeParity(char *); @@ -209,6 +209,11 @@ char *estr; str = buff; inp = inbuff; + if (strlen(str)>=IBSIZE){ + str[IBSIZE]=0; + LogPrintf(LOG_CHAT, "Truncating String to %d character: %s\n", IBSIZE, str); + } + nfds = modem + 1; s = str; for (;;) { @@ -245,8 +250,13 @@ char *estr; } if (FD_ISSET(modem, &rfds)) { /* got something */ if (DEV_IS_SYNC) { - nb = read(modem, inbuff, IBSIZE-1); - inbuff[nb] = 0; + int length; + if ((length=strlen(inbuff))>IBSIZE){ + bcopy(&(inbuff[IBSIZE]),inbuff,IBSIZE+1); /* shuffle down next part*/ + length=strlen(inbuff); + } + nb = read(modem, &(inbuff[length]), IBSIZE); + inbuff[nb + length] = 0; if (strstr(inbuff, str)) { #ifdef SIGALRM sigsetmask(omask); |