mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-15 23:05:49 +01:00
Make the implementation and documentation agree. Specifically:
- document that sysctl() and sysctlbyname() return 0 on success - if the provided buffer is too small, set errno to ENOMEM and return -1 instead of returning ENOMEM.
This commit is contained in:
parent
fae0c289fb
commit
eec1dbe6ce
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=42353
@ -667,9 +667,10 @@ If the amount of free and cache memory falls below this value, the
|
||||
pageout daemon will enter "memory conserving mode" to avoid deadlock.
|
||||
.El
|
||||
.Sh RETURN VALUES
|
||||
If the call to
|
||||
.Fn sysctl
|
||||
is successful, the number of bytes copied out is returned.
|
||||
and
|
||||
.Fn sysctlbyname
|
||||
return 0 when successful.
|
||||
Otherwise \-1 is returned and
|
||||
.Va errno
|
||||
is set appropriately.
|
||||
|
@ -66,16 +66,20 @@ sysctl(name, namelen, oldp, oldlenp, newp, newlen)
|
||||
|
||||
switch (name[1]) {
|
||||
case USER_CS_PATH:
|
||||
if (oldp && *oldlenp < sizeof(_PATH_STDPATH))
|
||||
return (ENOMEM);
|
||||
if (oldp && *oldlenp < sizeof(_PATH_STDPATH)) {
|
||||
errno = ENOMEM;
|
||||
return -1;
|
||||
}
|
||||
*oldlenp = sizeof(_PATH_STDPATH);
|
||||
if (oldp != NULL)
|
||||
memmove(oldp, _PATH_STDPATH, sizeof(_PATH_STDPATH));
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (oldp && *oldlenp < sizeof(int))
|
||||
return (ENOMEM);
|
||||
if (oldp && *oldlenp < sizeof(int)) {
|
||||
errno = ENOMEM;
|
||||
return (-1);
|
||||
}
|
||||
*oldlenp = sizeof(int);
|
||||
if (oldp == NULL)
|
||||
return (0);
|
||||
|
Loading…
Reference in New Issue
Block a user