mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-26 07:55:01 +00:00
pathchk: Ensure bytes >= 128 are considered non-portable characters.
This was not broken on architectures such as ARM where char is unsigned. Also, remove the first non-portable character from the output. POSIX does not require this, and printing the first byte may yield an invalid byte sequence with UTF-8. PR: bin/165988 Reported by: Nicolas Rachinsky
This commit is contained in:
parent
e4cf0633b8
commit
ea6247173f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=256800
@ -98,7 +98,7 @@ check(const char *path)
|
||||
{
|
||||
struct stat sb;
|
||||
long complen, namemax, pathmax, svnamemax;
|
||||
int badch, last;
|
||||
int last;
|
||||
char *end, *p, *pathd;
|
||||
|
||||
if ((pathd = strdup(path)) == NULL)
|
||||
@ -142,9 +142,9 @@ check(const char *path)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (pflag && (badch = portable(p)) >= 0) {
|
||||
if (pflag && !portable(p)) {
|
||||
warnx("%s: %s: component contains non-portable "
|
||||
"character `%c'", path, p, badch);
|
||||
"character", path, p);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
@ -183,8 +183,7 @@ bad: free(pathd);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check whether a path component contains only portable characters. Return
|
||||
* the first non-portable character found.
|
||||
* Check whether a path component contains only portable characters.
|
||||
*/
|
||||
static int
|
||||
portable(const char *path)
|
||||
@ -197,7 +196,7 @@ portable(const char *path)
|
||||
|
||||
s = strspn(path, charset);
|
||||
if (path[s] != '\0')
|
||||
return (path[s]);
|
||||
return (0);
|
||||
|
||||
return (-1);
|
||||
return (1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user