Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 May 2001 21:50:07 -0700
From:      Dima Dorfman <dima@unixfreak.org>
To:        audit@freebsd.org
Subject:   sysctl fix for zero-length data
Message-ID:  <20010601045007.629243E2F@bazooka.unixfreak.org>

next in thread | raw e-mail | index | archive | help
Please review the attached patch to fix the sysctl interface to accept
data of zero length.  This fixes the case where one wants to clear a
string exported via sysctl, as in:

	sysctl kern.hostname=

Right now, the above will do nothing.  With this patch, it will clear
(i.e., set to "") "kern.hostname".

Thanks,

					Dima Dorfman
					dima@unixfreak.org


Index: kern_sysctl.c
===================================================================
RCS file: /stl/src/FreeBSD/src/sys/kern/kern_sysctl.c,v
retrieving revision 1.107
diff -u -r1.107 kern_sysctl.c
--- kern_sysctl.c	2001/05/19 05:45:55	1.107
+++ kern_sysctl.c	2001/06/01 04:46:47
@@ -862,7 +907,7 @@
 		req.oldptr= old;
 	}
 
-	if (newlen) {
+	if (new != NULL) {
 		req.newlen = newlen;
 		req.newptr = new;
 	}
@@ -1126,7 +1171,7 @@
 		req.oldptr= old;
 	}
 
-	if (newlen) {
+	if (new != NULL) {
 		if (!useracc(new, req.newlen, VM_PROT_READ))
 			return (EFAULT);
 		req.newlen = newlen;

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




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