Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Oct 2009 15:57:00 +0100 (CET)
From:      Ulrich Spörlein <uqs@spoerlein.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/140016: sysctl(8) raise WARNS to 3
Message-ID:  <200910271457.n9REv0DQ085667@acme.spoerlein.net>
Resent-Message-ID: <200910271500.n9RF03a6035345@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         140016
>Category:       bin
>Synopsis:       sysctl(8) raise WARNS to 3
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 27 15:00:02 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Ulrich Spörlein
>Release:        FreeBSD 7.2-STABLE i386
>Organization:
>Environment:
	
>Description:
Fixes taken from DragonflyBSD
>How-To-Repeat:
	
>Fix:
	

--- sysctl.patch begins here ---

diff -r 4ac60f34976d -r 860e96dcdced sbin/sysctl/Makefile
--- a/sbin/sysctl/Makefile	Mon Oct 19 17:02:14 2009 +0200
+++ b/sbin/sysctl/Makefile	Mon Oct 19 17:17:13 2009 +0200
@@ -2,7 +2,7 @@
 # $FreeBSD$
 
 PROG=	sysctl
-WARNS?=	0
+WARNS?=	3
 MAN=	sysctl.8
 
 .include <bsd.prog.mk>
diff -r 4ac60f34976d -r 860e96dcdced sbin/sysctl/sysctl.c
--- a/sbin/sysctl/sysctl.c	Mon Oct 19 17:02:14 2009 +0200
+++ b/sbin/sysctl/sysctl.c	Mon Oct 19 17:17:13 2009 +0200
@@ -274,7 +274,10 @@
 			case CTLTYPE_STRING:
 				break;
 			case CTLTYPE_QUAD:
-				sscanf(newval, "%qd", &quadval);
+				quadval = strtoq(newval, &endptr, 0);
+				if (endptr == newval || *endptr != '\0')
+					errx(1, "invalid quad integer"
+					    " '%s'", (char *)newval);
 				newval = &quadval;
 				newsize = sizeof(quadval);
 				break;
@@ -329,7 +332,7 @@
 	struct clockinfo *ci = (struct clockinfo*)p;
 
 	if (l2 != sizeof(*ci)) {
-		warnx("S_clockinfo %d != %d", l2, sizeof(*ci));
+		warnx("S_clockinfo %d != %zu", l2, sizeof(*ci));
 		return (1);
 	}
 	printf(hflag ? "{ hz = %'d, tick = %'d, profhz = %'d, stathz = %'d }" :
@@ -344,7 +347,7 @@
 	struct loadavg *tv = (struct loadavg*)p;
 
 	if (l2 != sizeof(*tv)) {
-		warnx("S_loadavg %d != %d", l2, sizeof(*tv));
+		warnx("S_loadavg %d != %zu", l2, sizeof(*tv));
 		return (1);
 	}
 	printf(hflag ? "{ %'.2f %'.2f %'.2f }" : "{ %.2f %.2f %.2f }",
@@ -362,7 +365,7 @@
 	char *p1, *p2;
 
 	if (l2 != sizeof(*tv)) {
-		warnx("S_timeval %d != %d", l2, sizeof(*tv));
+		warnx("S_timeval %d != %zu", l2, sizeof(*tv));
 		return (1);
 	}
 	printf(hflag ? "{ sec = %'jd, usec = %'ld } " :
@@ -384,7 +387,7 @@
 	int pageKilo = getpagesize() / 1024;
 
 	if (l2 != sizeof(*v)) {
-		warnx("S_vmtotal %d != %d", l2, sizeof(*v));
+		warnx("S_vmtotal %d != %zu", l2, sizeof(*v));
 		return (1);
 	}
 
@@ -416,7 +419,7 @@
 	dev_t *d = (dev_t *)p;
 
 	if (l2 != sizeof(*d)) {
-		warnx("T_dev_T %d != %d", l2, sizeof(*d));
+		warnx("T_dev_T %d != %zu", l2, sizeof(*d));
 		return (1);
 	}
 	if ((int)(*d) != -1) {
@@ -520,7 +523,7 @@
 	j = sizeof(buf);
 	i = sysctl(qoid, len + 2, buf, &j, 0, 0);
 	if (i)
-		err(1, "sysctl fmt %d %d %d", i, j, errno);
+		err(1, "sysctl fmt %d %zu %d", i, j, errno);
 
 	if (kind)
 		*kind = *(u_int *)buf;
@@ -562,7 +565,7 @@
 	j = sizeof(name);
 	i = sysctl(qoid, nlen + 2, name, &j, 0, 0);
 	if (i || !j)
-		err(1, "sysctl name %d %d %d", i, j, errno);
+		err(1, "sysctl name %d %zu %d", i, j, errno);
 
 	if (Nflag) {
 		printf("%s", name);
@@ -613,7 +616,7 @@
 	case 'A':
 		if (!nflag)
 			printf("%s%s", name, sep);
-		printf("%.*s", len, p);
+		printf("%.*s", (int)len, p);
 		free(oval);
 		return (0);
 
@@ -700,7 +703,7 @@
 		}
 		if (!nflag)
 			printf("%s%s", name, sep);
-		printf("Format:%s Length:%d Dump:0x", fmt, len);
+		printf("Format:%s Length:%zu Dump:0x", fmt, len);
 		while (len-- && (xflag || p < val + 16))
 			printf("%02x", *p++);
 		if (!xflag && len > 16)
@@ -736,7 +739,7 @@
 			if (errno == ENOENT)
 				return (0);
 			else
-				err(1, "sysctl(getnext) %d %d", j, l2);
+				err(1, "sysctl(getnext) %d %zu", j, l2);
 		}
 
 		l2 /= sizeof(int);
--- sysctl.patch ends here ---


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



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