mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-04 09:09:56 +00:00
Better protection against too long pathes and 8bit controls in file
names, locate dumps core instead
This commit is contained in:
parent
f3b2d1fae4
commit
2fdd39d28d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=5761
@ -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 = '?';
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user