Describe the bug
xform_net_address() trims the input before detecting a four-byte binary IPv4 address. If the final address octet is also an ASCII whitespace byte, trim() removes it and the binary address is returned without conversion.
For example, binary c0 a8 01 0a (192.168.1.10) loses its final 0a byte.
To reproduce
Run from the plugin root:
php -r "require 'tests/bootstrap.php'; require 'lib/mactrack_functions.php'; var_dump(bin2hex(xform_net_address(hex2bin('c0a8010a'))));"
Observed:
Expected:
string(12) "192.168.1.10"
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
Detect and convert raw four-byte and sixteen-byte values before trimming textual input.
Describe the bug
xform_net_address()trims the input before detecting a four-byte binary IPv4 address. If the final address octet is also an ASCII whitespace byte,trim()removes it and the binary address is returned without conversion.For example, binary
c0 a8 01 0a(192.168.1.10) loses its final0abyte.To reproduce
Run from the plugin root:
php -r "require 'tests/bootstrap.php'; require 'lib/mactrack_functions.php'; var_dump(bin2hex(xform_net_address(hex2bin('c0a8010a'))));"Observed:
Expected:
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
Detect and convert raw four-byte and sixteen-byte values before trimming textual input.