Hi all, any thoughts on this behavior?
My main interest in this was that I was trying to add OpenBSD
support to a 3rd party, multi-platform sysctl library. In the
current implementation, this library was relying on the behavior
below to determine the required buffer size before performing the
read, which was failing for any entry that internally used the
sysctl_struct() function (sysctl_rdstruct() works fine).
I guess as a workaround a large oldp buffer could always be
passed in.
Thanks,
Nate
On Sun, Oct 03, 2021 at 06:32:38PM -0700, Nathan Houghton wrote:
> Hi all,
>
> I think I found some cases where the "oldlenp" value is not properly
> updated according to the details in the manual page. In particular
> this section from sysctl(2):
>
> The size of the available data can be determined by calling sysctl() with
> a NULL parameter for oldp. The size of the available data will be
> returned in the location pointed to by oldlenp.
>
> This seems to work fine for most cases, but when testing the program
> below I found that for some MIB paths, the oldlenp value is not
> updated.
>
> System details: OpenBSD 6.9, amd64, with all patches applied via syspatch
>
> ---8<----
> #include <stdio.h>
>
> #include <sys/queue.h>
> #include <sys/types.h>
> #include <sys/sysctl.h>
> #include <sys/socket.h>
>
> #include <netinet/in.h>
> #include <netinet/tcp.h>
> #include <netinet/tcp_timer.h>
> #include <netinet/tcp_var.h>
>
> int main(int argc, char **argv)
> {
> #if 1
> /* working case, prints: "r: 0, len: 4" */
> int path[] = { CTL_NET, PF_INET, IPPROTO_TCP, TCPCTL_SYN_HASH_SIZE };
> #else
> /* failing case, prints: "r: 0, len: 0" */
> int path[] = { CTL_NET, PF_INET, IPPROTO_TCP, TCPCTL_BADDYNAMIC };
>
No comments:
Post a Comment