You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Compressed IPv6 addresses are corrupted by xform_net_address #355
xform_net_address() converts valid short/compressed IPv6 text as though it were a colon-delimited hexadecimal IPv4 value.
For example, 2001:db8::1 becomes 8193.3512.0.1. The function currently assumes any colon-delimited input with a string length of 11 characters or fewer is hexadecimal IPv4.
The behavior was reproduced in clean PHP 8.1, 8.2, 8.3, and 8.4 Docker containers while building the cohesive MacTrack test suite.
Suggested direction
Recognize valid IPv6 text (for example with filter_var(..., FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) before applying the legacy hexadecimal IPv4 conversion.
Still reproduces on develop at 867ca5b: 2001:db8::1 becomes 8193.3512.0.1. #356 (binary addresses truncated by trim()) and #351 item 2 (trim(null)) are in the same function, so these should be fixed and tested together.
Proposed check order for xform_net_address(), covering this issue, #356 and #351 item 2 in one change. Raw binary values are converted before any trim(), and valid IP text is returned before the legacy hexadecimal conversion runs.
flowchart TD
in["Value from SNMP"] --> b4{"4 bytes and not<br/>valid IP text?"}
b4 -- "Yes" --> v4["Convert to dotted IPv4"]
b4 -- "No" --> b16{"16 bytes and not<br/>valid IP text?"}
b16 -- "Yes" --> v6["Convert to IPv6 text"]
b16 -- "No" --> t["Cast to string, then trim"]
t --> ok{"Valid IPv4 or IPv6 text?"}
ok -- "Yes" --> keep["Return unchanged"]
ok -- "No" --> hex["Legacy hexadecimal conversion"]
Activity
somethingwithproof commentedon Nov 9, 2026
Still reproduces on
developat 867ca5b:2001:db8::1becomes8193.3512.0.1. #356 (binary addresses truncated bytrim()) and #351 item 2 (trim(null)) are in the same function, so these should be fixed and tested together.somethingwithproof commentedon Nov 9, 2026
Proposed check order for
xform_net_address(), covering this issue, #356 and #351 item 2 in one change. Raw binary values are converted before anytrim(), and valid IP text is returned before the legacy hexadecimal conversion runs.flowchart TD in["Value from SNMP"] --> b4{"4 bytes and not<br/>valid IP text?"} b4 -- "Yes" --> v4["Convert to dotted IPv4"] b4 -- "No" --> b16{"16 bytes and not<br/>valid IP text?"} b16 -- "Yes" --> v6["Convert to IPv6 text"] b16 -- "No" --> t["Cast to string, then trim"] t --> ok{"Valid IPv4 or IPv6 text?"} ok -- "Yes" --> keep["Return unchanged"] ok -- "No" --> hex["Legacy hexadecimal conversion"]