]> granicus.if.org Git - php/commitdiff
Fix long2ip's handling of unsigned longs, by accepting a string argument and
authorSterling Hughes <sterling@php.net>
Fri, 7 Dec 2001 13:20:18 +0000 (13:20 +0000)
committerSterling Hughes <sterling@php.net>
Fri, 7 Dec 2001 13:20:18 +0000 (13:20 +0000)
then manually converting the string to an unsigned long using strtoul()

ext/standard/basic_functions.c

index fc70fb8fa1198f07fd1b2c85802fab6b0399e8fd..ed7dbccc73ef6a06a3487f4736c11a7d97891a5c 100644 (file)
@@ -1153,15 +1153,17 @@ PHP_FUNCTION(ip2long)
 PHP_FUNCTION(long2ip)
 {
        zval **num;
+       unsigned long n;
        struct in_addr myaddr;
 
        if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
                WRONG_PARAM_COUNT;
        }
+       convert_to_string_ex(num);
+       
+       n = strtoul(Z_STRVAL_PP(num), NULL, 0);
 
-       convert_to_long_ex(num);
-       myaddr.s_addr = htonl((unsigned long) Z_LVAL_PP(num));
-
+       myaddr.s_addr = htonl(n);
        RETURN_STRING(inet_ntoa(myaddr), 1);
 }
 /* }}} */
@@ -2882,7 +2884,7 @@ PHP_FUNCTION(import_request_variables)
  * tab-width: 4
  * c-basic-offset: 4
  * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
+ * vim600: fdm=marker
+ * vim: noet sw=4 ts=4
  */