From: Derick Rethans Date: Fri, 28 May 2004 10:45:18 +0000 (+0000) Subject: - Fixed ip2long() behavior if an invalid IP address was passed to the X-Git-Tag: php-5.0.0RC3RC2~83 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f964cc09d2b4537c27c291fac1d2124f62fa1a3f;p=php - Fixed ip2long() behavior if an invalid IP address was passed to the function. This makes it possible to distingiush between "255.255.255.255" and a wrong one. --- diff --git a/NEWS b/NEWS index 88a95df6df..fbb5c4596f 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,8 @@ PHP NEWS - Changed class type hints for function parameters to not allow the passing of NULL values. (Andi) - Changed tidy_node to tidyNode and removed tidy_exception. (John) +- Fixed ip2long() to return FALSE if an IP address passed to this function + is not valid. (Derick) - Fixed memory leak in memory manager. (Andi) - Fixed problem with exceptions returning from include(). (Dmitry) - Fixed bug #28311 (Transparency detection code is off by 1). diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 6fcab6d761..425d6a494f 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -1247,7 +1247,7 @@ PHP_FUNCTION(ip2long) convert_to_string_ex(str); if (Z_STRLEN_PP(str) == 0 || (ip = inet_addr(Z_STRVAL_PP(str))) == INADDR_NONE) { - RETURN_LONG(-1); + RETURN_FALSE; } RETURN_LONG(ntohl(ip));