summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2009-05-15 14:41:44 +0000
committerkib <kib@FreeBSD.org>2009-05-15 14:41:44 +0000
commitb8162aa0c9949012533f0436d057c8cc5bea571d (patch)
treea1e1849bdaee878cee7f1db0dbcc112f176a05e1 /sys/kern/kern_sysctl.c
parent8a2fb32a355e541af361a07d738b6d02936d1e43 (diff)
downloadFreeBSD-src-b8162aa0c9949012533f0436d057c8cc5bea571d.zip
FreeBSD-src-b8162aa0c9949012533f0436d057c8cc5bea571d.tar.gz
Revert r192094. The revision caused problems for sysctl(3) consumers
that expect that oldlen is filled with required buffer length even when supplied buffer is too short and returned error is ENOMEM. Redo the fix for kern.proc.filedesc, by reverting the req->oldidx when remaining buffer space is too short for the current kinfo_file structure. Also, only ignore ENOMEM. We have to convert ENOMEM to no error condition to keep existing interface for the sysctl, though. Reported by: ed, Florian Smeets <flo kasimir com> Tested by: pho
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r--sys/kern/kern_sysctl.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index bf539be..0a8a096 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1223,9 +1223,9 @@ sysctl_old_kernel(struct sysctl_req *req, const void *p, size_t l)
if (i > 0)
bcopy(p, (char *)req->oldptr + req->oldidx, i);
}
+ req->oldidx += l;
if (req->oldptr && i != l)
return (ENOMEM);
- req->oldidx += l;
return (0);
}
@@ -1322,10 +1322,9 @@ sysctl_old_user(struct sysctl_req *req, const void *p, size_t l)
size_t i, len, origidx;
origidx = req->oldidx;
- if (req->oldptr == NULL) {
- req->oldidx += l;
+ req->oldidx += l;
+ if (req->oldptr == NULL)
return (0);
- }
/*
* If we have not wired the user supplied buffer and we are currently
* holding locks, drop a witness warning, as it's possible that
@@ -1347,7 +1346,6 @@ sysctl_old_user(struct sysctl_req *req, const void *p, size_t l)
return (error);
if (i < l)
return (ENOMEM);
- req->oldidx += l;
return (0);
}
OpenPOWER on IntegriCloud