summaryrefslogtreecommitdiff
path: root/ext/standard/basic_functions.c
diff options
context:
space:
mode:
authorSterling Hughes <sterling@php.net>2001-12-07 13:20:18 +0000
committerSterling Hughes <sterling@php.net>2001-12-07 13:20:18 +0000
commitd95a4e2c19d1b9c791efa361648606247637e768 (patch)
treece2136553489f3cf0f620fee171b5de66dc24d91 /ext/standard/basic_functions.c
parent836e8af6ff7df94c1923ba1e4db9ac679c650428 (diff)
downloadphp-git-d95a4e2c19d1b9c791efa361648606247637e768.tar.gz
Fix long2ip's handling of unsigned longs, by accepting a string argument and
then manually converting the string to an unsigned long using strtoul()
Diffstat (limited to 'ext/standard/basic_functions.c')
-rw-r--r--ext/standard/basic_functions.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index fc70fb8fa1..ed7dbccc73 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -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
*/