bin/123807: [patch] timed does not run on arm (incorrect getopt usage)

Matthew Luckie mjl at luckie.org.nz
Mon May 19 07:30:08 UTC 2008


>Number:         123807
>Category:       bin
>Synopsis:       [patch] timed does not run on arm (incorrect getopt usage)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon May 19 07:30:07 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Matthew Luckie
>Release:        FreeBSD 7.0-RELEASE-p1 arm
>Organization:
>Environment:
System: FreeBSD vinyl.luckie.org.nz 7.0-RELEASE-p1 FreeBSD 7.0-RELEASE-p1 #4: Sun May 18 08:49:48 NZST 2008     root at rayon.luckie.org.nz:/usr/obj/arm/usr/src/sys/vinyl  arm
>Description:
getopt returns an integer, -1 when there is no further options to parse.
char on arm is an unsigned byte value, so it cannot hold -1.
therefore the getopt hack to hold the return value in a char and loop on that
will fail and leave the application in an infinite loop
>How-To-Repeat:
run timed on systems where char is unsigned.
>Fix:

	

--- patch-timed.c begins here ---
--- usr.sbin/timed/timed/timed.c.orig	2003-07-06 22:37:00.000000000 +1200
+++ usr.sbin/timed/timed/timed.c	2008-05-19 19:14:26.000000000 +1200
@@ -134,7 +134,7 @@ main(argc, argv)
 	struct nets *nt;
 	struct sockaddr_in server;
 	u_short port;
-	char c;
+	int c;
 
 #ifdef lint
 	ntip = NULL;
@@ -147,7 +147,7 @@ main(argc, argv)
 
 	opterr = 0;
 	while ((c = getopt(argc, argv, "Mtdn:i:F:G:P:")) != -1) {
-		switch (c) {
+		switch ((char)c) {
 		case 'M':
 			Mflag = 1;
 			break;
--- patch-timed.c ends here ---


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list