summaryrefslogtreecommitdiffstats
path: root/usr.bin/locate
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-01-21 05:50:50 +0000
committerache <ache@FreeBSD.org>1995-01-21 05:50:50 +0000
commit546fa44779e7010e2501d1b34759fd6b2360946b (patch)
tree399db9cea730e06afbba0814fa05dccdc8ade9cb /usr.bin/locate
parentbf096f839ffdfd4c0bcf321e659b609f87898f79 (diff)
downloadFreeBSD-src-546fa44779e7010e2501d1b34759fd6b2360946b.zip
FreeBSD-src-546fa44779e7010e2501d1b34759fd6b2360946b.tar.gz
Better protection against too long pathes and 8bit controls in file
names, locate dumps core instead
Diffstat (limited to 'usr.bin/locate')
-rw-r--r--usr.bin/locate/code/locate.code.c8
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 d3ec29f..a7506ec 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 = '?';
}
OpenPOWER on IntegriCloud