diff options
author | Andrey A. Chernov <ache@FreeBSD.org> | 1995-01-21 05:50:50 +0000 |
---|---|---|
committer | Andrey A. Chernov <ache@FreeBSD.org> | 1995-01-21 05:50:50 +0000 |
commit | 2fdd39d28df3ee6f82b6242eb21fb4b1229e927c (patch) | |
tree | 399db9cea730e06afbba0814fa05dccdc8ade9cb /usr.bin/locate | |
parent | f3b2d1fae46df46fe7a87454f7a5feb9e22e0fc4 (diff) | |
download | src-2fdd39d28df3ee6f82b6242eb21fb4b1229e927c.tar.gz src-2fdd39d28df3ee6f82b6242eb21fb4b1229e927c.zip |
Better protection against too long pathes and 8bit controls in file
names, locate dumps core instead
Notes
Notes:
svn path=/head/; revision=5761
Diffstat (limited to 'usr.bin/locate')
-rw-r--r-- | usr.bin/locate/code/locate.code.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/locate/code/locate.code.c b/usr.bin/locate/code/locate.code.c index d3ec29f4bc71..a7506ec2d417 100644 --- a/usr.bin/locate/code/locate.code.c +++ b/usr.bin/locate/code/locate.code.c @@ -89,8 +89,8 @@ static char sccsid[] = "@(#)locate.code.c 8.1 (Berkeley) 6/6/93"; #define BGBUFSIZE (NBG * 2) /* size of bigram buffer */ -char buf1[MAXPATHLEN] = " "; -char buf2[MAXPATHLEN]; +char buf1[MAXPATHLEN + 1] = " "; +char buf2[MAXPATHLEN + 1]; char bigrams[BGBUFSIZE + 1] = { 0 }; int bgindex __P((char *)); @@ -129,7 +129,7 @@ main(argc, argv) oldpath = buf1; path = buf2; oldcount = 0; - while (fgets(path, sizeof(buf2), stdin) != NULL) { + while (fgets(path, sizeof(buf2) - 1, stdin) != NULL) { /* Truncate newline. */ cp = path + strlen(path) - 1; if (cp > path && *cp == '\n') @@ -139,7 +139,7 @@ main(argc, argv) for (cp = path; *cp != NULL; cp++) { if ((u_char)*cp >= PARITY) *cp &= PARITY-1; - else if (*cp <= SWITCH) + if (*cp <= SWITCH) *cp = '?'; } |