From: Ian Darwin Date: Fri, 19 Feb 1993 14:22:45 +0000 (+0000) Subject: Part of Guy Harris' Jan-93 rewrite, including: X-Git-Tag: FILE3_27~184 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=560a8d7939bdfc1cab43a9c36fdc3df07cb1e81b;p=file Part of Guy Harris' Jan-93 rewrite, including: Put an extra '\0' at the end of the buffer before handing it to "tryit()"; "ascmagic()" assumes the buffer is a '\0'-terminated string, as it runs a copy of it through "strtok()". --- diff --git a/src/file.c b/src/file.c index 2bb73286..7de0ea57 100644 --- a/src/file.c +++ b/src/file.c @@ -26,7 +26,7 @@ */ #ifndef lint static char *moduleid = - "@(#)$Id: file.c,v 1.25 1992/09/11 13:15:16 ian Exp $"; + "@(#)$Id: file.c,v 1.26 1993/02/19 14:22:45 ian Exp $"; #endif /* lint */ #include @@ -186,7 +186,7 @@ int wid; { int fd = 0; static const char stdname[] = "standard input"; - unsigned char buf[HOWMANY]; + unsigned char buf[HOWMANY+1]; /* one extra for terminating '\0' */ struct utimbuf utbuf; struct stat sb; int nbytes = 0; /* number of bytes read from a datafile */ @@ -233,8 +233,10 @@ int wid; if (nbytes == 0) ckfputs("empty", stdout); - else + else { + buf[nbytes] = '\0'; /* null-terminate it */ tryit(buf, nbytes); + } if (inname != stdname) { /*