From f964cc09d2b4537c27c291fac1d2124f62fa1a3f Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Fri, 28 May 2004 10:45:18 +0000 Subject: [PATCH] - 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. --- NEWS | 2 ++ ext/standard/basic_functions.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) 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)); -- 2.40.0