HomeFreeBSD

libc: return partial sysctl() result if buffer is too small

Description

libc: return partial sysctl() result if buffer is too small

Testing of a new feature revealed that calling sysctl() to retrieve
the value of the user.localbase variable passing too low a buffer size
could leave the result buffer unchanged.

The behavior in the normal case of a sufficiently large buffer was
correct.

All known callers pass a sufficiently large buffer and have thus not
been affected by this issue. If a non-default value had been assigned
to this variable, the result was as documented, too.

Fix the function to fill the buffer with a partial result, if the
passed in buffer size is too low to hold the full result.

MFC after: 3 days

Details

Provenance
seAuthored on Feb 4 2022, 12:44 PM
Parents
rG9596b349bb57: x86 atomic.h: remove obsoleted comment
Branches
Unknown
Tags
Unknown