From owner-freebsd-current Tue Apr 2 20:04:28 1996 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id UAA06657 for current-outgoing; Tue, 2 Apr 1996 20:04:28 -0800 (PST) Received: from ambrisko.roble.com (ambrisko@netcom7.netcom.com [192.100.81.115]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id UAA06649 for ; Tue, 2 Apr 1996 20:04:20 -0800 (PST) Received: from big.ambrisko.com (big [1.1.1.4]) by ambrisko.roble.com (8.6.12/8.6.9) with ESMTP id TAA29047 for ; Tue, 2 Apr 1996 19:57:27 -0800 Received: (from ambrisko@localhost) by big.ambrisko.com (8.7.5/8.6.9) id TAA00820 for freebsd-current@freebsd.org; Tue, 2 Apr 1996 19:56:49 -0800 (PST) Message-Id: <199604030356.TAA00820@big.ambrisko.com> Subject: iijppp chat.c patch To: freebsd-current@freebsd.org Date: Tue, 2 Apr 1996 19:56:48 -0800 (PST) From: "Doug Ambrisko" X-Mailer: ELM [version 2.4 PL25 ME8b] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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. Doug A. *** chat.c.orig Thu Mar 28 18:59:09 1996 --- chat.c Tue Apr 2 19:48:41 1996 *************** *** 45,51 **** static int abort_next, timeout_next; static int numaborts; char *AbortStrings[50]; ! char inbuff[IBSIZE]; extern int ChangeParity(char *); --- 45,51 ---- static int abort_next, timeout_next; static int numaborts; char *AbortStrings[50]; ! char inbuff[IBSIZE*2+1]; extern int ChangeParity(char *); *************** *** 209,214 **** --- 209,219 ---- 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,252 **** } if (FD_ISSET(modem, &rfds)) { /* got something */ if (DEV_IS_SYNC) { ! nb = read(modem, inbuff, IBSIZE-1); ! inbuff[nb] = 0; if (strstr(inbuff, str)) { #ifdef SIGALRM sigsetmask(omask); --- 250,262 ---- } if (FD_ISSET(modem, &rfds)) { /* got something */ if (DEV_IS_SYNC) { ! 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);