]> granicus.if.org Git - php/commitdiff
MFH: fix #29737 (ip2long should return -1 if IP is 255.255.255.255 and FALSE on error)
authorAntony Dovgal <tony2001@php.net>
Thu, 19 Aug 2004 14:03:44 +0000 (14:03 +0000)
committerAntony Dovgal <tony2001@php.net>
Thu, 19 Aug 2004 14:03:44 +0000 (14:03 +0000)
ext/standard/basic_functions.c

index 61b2a8bf3078329c4ee863b92c7f8646ec6e536d..9e0bf9bf5e64a70e02287c574b04a6a47cfe0e74 100644 (file)
@@ -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;
        }