DragonFly BSD
DragonFly submit List (threaded) for 2005-09
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

basename bug [patch attached]


From: Kyle Butt <kylebutt@xxxxxxxxx>
Date: Thu, 22 Sep 2005 14:47:29 -0600

I found a bug in basename (discovered via pkgsrc) and I've
attached a patch to fix it. Hopefully this helps.

Kyle.
Index: basename.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/basename/basename.c,v
retrieving revision 1.5
diff -u -u -r1.5 basename.c
--- basename.c	18 Sep 2005 10:12:55 -0000	1.5
+++ basename.c	22 Sep 2005 20:23:25 -0000
@@ -59,8 +59,8 @@
 
 	setlocale(LC_ALL, "");
 	
-	suffix = 0;
-	suffixlen = NULL;
+	suffix = NULL;
+	suffixlen = 0;
 
 	while ((ch = getopt(argc, argv, "")) != -1)
 		switch(ch) {
@@ -80,6 +80,10 @@
 	}
 	if ((p = basename(argv[0])) == NULL)
 		err(1, "%s", argv[0]);
+	if (argc == 2) {
+		suffix = argv[1];
+		suffixlen = strlen(argv[1]);
+	}
 	stripsuffix(p, suffix, suffixlen);
 	(void)printf("%s\n", p);
 	exit(0);


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]