From: Antony Dovgal Date: Thu, 19 Aug 2004 14:03:44 +0000 (+0000) Subject: MFH: fix #29737 (ip2long should return -1 if IP is 255.255.255.255 and FALSE on error) X-Git-Tag: php-5.0.2RC1~117 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4945317c2876b8deee61aa19b77d8e9be51f64b3;p=php MFH: fix #29737 (ip2long should return -1 if IP is 255.255.255.255 and FALSE on error) --- diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 61b2a8bf30..9e0bf9bf5e 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1280,6 +1280,13 @@ PHP_FUNCTION(ip2long) convert_to_string_ex(str); + /* the only special case when we should return -1 ourselves, + * because inet_addr() considers it wrong. + */ + if (!strcasecmp(Z_STRVAL_PP(str), "255.255.255.255")) { + RETURN_LONG(-1); + } + if (Z_STRLEN_PP(str) == 0 || (ip = inet_addr(Z_STRVAL_PP(str))) == INADDR_NONE) { RETURN_FALSE; }