svn commit: r240176 - head/lib/libc/gen
Tom Rhodes
trhodes at FreeBSD.org
Thu Sep 6 20:15:44 UTC 2012
Author: trhodes
Date: Thu Sep 6 20:15:44 2012
New Revision: 240176
URL: http://svn.freebsd.org/changeset/base/240176
Log:
Avoid segfault if name is invalid. Basically, only
check for CTL_USER if the sysctl fails with ENOENT.
PR: 169056
Reviewed by: jhb
Modified:
head/lib/libc/gen/sysctl.c
Modified: head/lib/libc/gen/sysctl.c
==============================================================================
--- head/lib/libc/gen/sysctl.c Thu Sep 6 19:26:59 2012 (r240175)
+++ head/lib/libc/gen/sysctl.c Thu Sep 6 20:15:44 2012 (r240176)
@@ -50,8 +50,11 @@ int
sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp,
const void *newp, size_t newlen)
{
- if (name[0] != CTL_USER)
- return (__sysctl(name, namelen, oldp, oldlenp, newp, newlen));
+ int retval;
+
+ retval = __sysctl(name, namelen, oldp, oldlenp, newp, newlen);
+ if (retval != -1 || errno != ENOENT || name[0] != CTL_USER)
+ return (retval);
if (newp != NULL) {
errno = EPERM;
More information about the svn-src-head
mailing list