Skip to content

Return complete bytes for OPAQUE and STRUCT sysctl values - #23

Open
gronke wants to merge 2 commits into
mainfrom
fix/opaque-truncation
Open

gronke wants to merge 2 commits into
mainfrom
fix/opaque-truncation

Conversation

@gronke

@gronke gronke commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Reading an OPAQUE or STRUCT sysctl returned a value truncated at the first NUL byte, reported upstream as #20.
The base CtlType.value fallback read the .value of a ctypes.c_char array, which follows C string semantics.

Changes:

  • query_value() hands the raw buffer bytes to the value class, so CtlType.data is plain bytes.
  • The base CtlType.value returns the complete bytes when no unpack format is defined; only STRING keeps NUL termination semantics.
  • New test byte-compares kern.boottime, kern.clockrate and vm.loadavg against /sbin/sysctl -b.

gronke added 2 commits July 6, 2026 18:43
The fallback read the .value of a c_char array, which follows C string
semantics and truncated OPAQUE and STRUCT values at the first NUL byte.
CtlType.data now holds the plain buffer bytes and only STRING keeps the
NUL termination semantics.
Fixes #20.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant