PATCH: fix for broken run-parts

Gabriel L. Somlo somlo at cmu.edu
Fri Apr 27 16:52:51 UTC 2007


Hi,

I noticed run-parts kept failing on me, and tracked it down to the
fact that my file names happened to contain a '.' character, which
upset the invalid_name() function :)

So, here's a patch that fixes invalid_name() and IMHO makes it
prettier, too :)

Please apply if you like.

Regards,
Gabriel

diff -NarU5 busybox-svn-18518.orig/debianutils/run_parts.c busybox-svn-18518/debianutils/run_parts.c
--- busybox-svn-18518.orig/debianutils/run_parts.c	2007-04-26 17:29:48.000000000 -0400
+++ busybox-svn-18518/debianutils/run_parts.c	2007-04-27 12:45:34.000000000 -0400
@@ -58,16 +58,16 @@
 /* True or false? Is this a valid filename (upper/lower alpha, digits,
  * underscores, and hyphens only?)
  */
 static bool invalid_name(const char *c)
 {
-	while (*c) {
-		if (!isalnum(*c) && (*c != '_') && (*c != '-' && (*c != '/'))) {
-			return 1;
-		}
-		++c;
-	}
+	while (*c && (isalnum(*c) || strchr("._-/", *c)))
+		c++;
+
+	if (*c)
+		return 1;
+
 	return 0;
 }
 #define RUN_PARTS_OPT_a (1<<0)
 #define RUN_PARTS_OPT_u (1<<1)
 #define RUN_PARTS_OPT_t (1<<2)


More information about the busybox mailing list