Comment 1 for bug 1865067

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I believe the bug is in lib/api_automation.php's automation_get_valid_mask($range) function.

It uses bindec() to convert binary to integer, but the result of bindec() is unsigned integer, or float if it's too big for an integer[1]. On 32bit turns out it's too big for an integer, a float is returned, and things break.

On 64bit:
 php ./test.php 24

bindec(11111111111111111111111100000000):
4294967040
Array
(
    [cidr] => 24
    [subnet] => 255.255.255.0
    [count] => 255
)

Same code on 32bits:
ubuntu@f1-armhf:~$ php ./test.php 24

bindec(11111111111111111111111100000000):
4294967040PHP Warning: long2ip() expects parameter 1 to be int, float given in /home/ubuntu/test.php on line 13

Array
(
    [cidr] => 24
    [subnet] =>
    [count] => 255
)

1. https://www.php.net/manual/en/function.bindec.php