]> granicus.if.org Git - file/commitdiff
Bug fix from Don Seeley at BSDI. make sure that the string is
authorChristos Zoulas <christos@zoulas.com>
Fri, 21 Jan 1994 01:25:30 +0000 (01:25 +0000)
committerChristos Zoulas <christos@zoulas.com>
Fri, 21 Jan 1994 01:25:30 +0000 (01:25 +0000)
null terminated before calling strtok.

src/ascmagic.c

index 9821a46bee1f479d99025803044f3a78e2b27434..600b0ab9d568a800e63e5c51eec537df98ef1b87 100644 (file)
@@ -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' */