Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 31 Aug 2014 20:34:07 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r270890 - stable/10/usr.bin/pathchk
Message-ID:  <201408312034.s7VKY7PG053863@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Sun Aug 31 20:34:06 2014
New Revision: 270890
URL: http://svnweb.freebsd.org/changeset/base/270890

Log:
  MFC r256800: 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:		165988
  Reported by:	Nicolas Rachinsky
  Relnotes:	yes

Modified:
  stable/10/usr.bin/pathchk/pathchk.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/pathchk/pathchk.c
==============================================================================
--- stable/10/usr.bin/pathchk/pathchk.c	Sun Aug 31 20:23:56 2014	(r270889)
+++ stable/10/usr.bin/pathchk/pathchk.c	Sun Aug 31 20:34:06 2014	(r270890)
@@ -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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408312034.s7VKY7PG053863>