aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2013-10-20 20:10:31 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2013-10-20 20:10:31 +0000
commitea6247173fd06101e7fd7624a9895f2340bce3d2 (patch)
treec35fd99405fbbf51fd14024f667fa3dd655725f1 /usr.bin
parente4cf0633b81b8e9f11b56700e79761cf3702823b (diff)
downloadsrc-ea6247173fd06101e7fd7624a9895f2340bce3d2.tar.gz
src-ea6247173fd06101e7fd7624a9895f2340bce3d2.zip
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
Notes
Notes: svn path=/head/; revision=256800
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/pathchk/pathchk.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/usr.bin/pathchk/pathchk.c b/usr.bin/pathchk/pathchk.c
index 2d8fa595d32d..3dc901bb0498 100644
--- a/usr.bin/pathchk/pathchk.c
+++ b/usr.bin/pathchk/pathchk.c
@@ -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);
}