From: Christos Zoulas Date: Fri, 21 Jan 1994 01:25:30 +0000 (+0000) Subject: Bug fix from Don Seeley at BSDI. make sure that the string is X-Git-Tag: FILE3_27~122 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0fa1f57e395e142353b678dd77fdc1f6c6596d64;p=file Bug fix from Don Seeley at BSDI. make sure that the string is null terminated before calling strtok. --- diff --git a/src/ascmagic.c b/src/ascmagic.c index 9821a46b..600b0ab9 100644 --- a/src/ascmagic.c +++ b/src/ascmagic.c @@ -36,7 +36,7 @@ #ifndef lint static char *moduleid = - "@(#)$Id: ascmagic.c,v 1.16 1993/10/27 21:00:54 christos Exp $"; + "@(#)$Id: ascmagic.c,v 1.17 1994/01/21 01:25:30 christos Exp $"; #endif /* lint */ /* an optimisation over plain strcmp() */ @@ -80,6 +80,7 @@ int nbytes; /* size actually read */ /* look for tokens from names.h - this is expensive! */ /* make a copy of the buffer here because strtok() will destroy it */ s = (unsigned char*) memcpy(nbuf, buf, nbytes); + s[nbytes] = '\0'; has_escapes = (memchr(s, '\033', nbytes) != NULL); while ((token = strtok((char*)s, " \t\n\r\f")) != NULL) { s = NULL; /* make strtok() keep on tokin' */