From: Derick Rethans Date: Sat, 1 Sep 2007 18:37:27 +0000 (+0000) Subject: - Fixed bug #42512 (ip2long('255.255.255.255') should return 4294967295 on X-Git-Tag: RELEASE_2_0_0a1~1896 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=773fe3adc7444b37a74a27c3ac3267a945f6c95d;p=php - Fixed bug #42512 (ip2long('255.255.255.255') should return 4294967295 on 64-bit PHP). --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index fa5ea69e02..01beaf8fb2 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -4284,7 +4284,7 @@ PHP_FUNCTION(ip2long) */ if (addr_len == sizeof("255.255.255.255") - 1 && !memcmp(addr, "255.255.255.255", sizeof("255.255.255.255") - 1)) { - RETURN_LONG(-1); + RETURN_LONG(0xFFFFFFFF); } RETURN_FALSE; diff --git a/ext/standard/tests/network/ip_x86_64.phpt b/ext/standard/tests/network/ip_x86_64.phpt new file mode 100644 index 0000000000..bc3e72c2a2 --- /dev/null +++ b/ext/standard/tests/network/ip_x86_64.phpt @@ -0,0 +1,67 @@ +--TEST-- +ip2long() & long2ip() tests +--SKIPIF-- +32bit platform only"); +?> +--FILE-- + +--EXPECTF-- +int(2130706433) +string(9) "127.0.0.1" +int(167772161) +string(8) "10.0.0.1" +int(4294967295) +string(15) "255.255.255.255" +int(4294967040) +string(13) "255.255.255.0" +int(0) +string(7) "0.0.0.0" +int(1118019956) +string(14) "66.163.161.116" + +Warning: Wrong parameter count for ip2long() in %s on line %d +NULL +bool(false) +bool(false) +int(1869573999) + +Notice: Array to string conversion in %s on line %d +bool(false) + +Warning: Wrong parameter count for long2ip() in %s on line %d +NULL +string(13) "255.254.82.80" +string(7) "0.0.0.0" + +Notice: Array to string conversion in %s on line %d +string(7) "0.0.0.0" +Done