iliaa           Fri Dec 19 08:33:52 2003 EDT

  Modified files:              
    /php-src/ext/standard       basic_functions.c 
  Log:
  Fixed bug #26667 (Added safety checks to ip2long()).
  
  
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.646 
php-src/ext/standard/basic_functions.c:1.647
--- php-src/ext/standard/basic_functions.c:1.646        Sun Dec 14 07:32:35 2003
+++ php-src/ext/standard/basic_functions.c      Fri Dec 19 08:33:51 2003
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: basic_functions.c,v 1.646 2003/12/14 12:32:35 zeev Exp $ */
+/* $Id: basic_functions.c,v 1.647 2003/12/19 13:33:51 iliaa Exp $ */
 
 #include "php.h"
 #include "php_streams.h"
@@ -1181,6 +1181,7 @@
 PHP_FUNCTION(ip2long)
 {
        zval **str;
+       unsigned long int ip;
 
        if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &str) == FAILURE) {
                WRONG_PARAM_COUNT;
@@ -1188,7 +1189,11 @@
 
        convert_to_string_ex(str);
 
-       RETURN_LONG(ntohl(inet_addr(Z_STRVAL_PP(str))));
+       if (Z_STRVAL_PP(str) == "" || (ip = inet_addr(Z_STRVAL_PP(str))) == 
INADDR_NONE) {
+               RETURN_LONG(-1);
+       }
+
+       RETURN_LONG(ntohl(ip));
 }
 /* }}} */
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to