svn: /php/php-src/ branches/PHP_5_2/NEWS branches/PHP_5_2/ext/standard/basic_functions.c branches/PHP_5_3/NEWS
branches/PHP_5_3/ext/standard/basic_functions.c trunk/ext/standard/basic_functions.c
| From: | Ilia Alshanetsky | Date: | Mon, 05 Oct 2009 14:45:54 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_2/NEWS branches/PHP_5_2/ext/standard/basic_functions.c branches/PHP_5_3/NEWS branches/PHP_5_3/ext/standard/basic_functions.c trunk/ext/standard/basic_functions.c |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-60584@lists.php.net to get a copy of this message | ||
iliaa Mon, 05 Oct 2009 14:45:54 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=289216
Log:
Fixed bug #49757 (long2ip() can return wrong value in a multi-threaded applications).
# original patch by Florian Anderiasch
Bug: http://bugs.php.net/49757 (Open) long2ip can return
wrong value in a multi-threaded application
Changed paths:
U php/php-src/branches/PHP_5_2/NEWS
U php/php-src/branches/PHP_5_2/ext/standard/basic_functions.c
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/standard/basic_functions.c
U php/php-src/trunk/ext/standard/basic_functions.c
Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS 2009-10-05 14:15:15 UTC (rev 289215)
+++ php/php-src/branches/PHP_5_2/NEWS 2009-10-05 14:45:54 UTC (rev 289216)
@@ -5,6 +5,8 @@
(Rasmus)
- Fixed a open_basedir bypass in posix_mkfifo() identified by Grzegorz
Stachowiak. (Rasmus)
+- Fixed bug #49757 (long2ip() can return wrong value in a multi-threaded
+ applications). (Ilia, Florian Anderiasch)
- Fixed bug #49698 (Unexpected change in strnatcasecmp()). (Rasmus)
- Fixed bug #49647 (DOMUserData does not exist). (Rob)
- Fixed bug #49630 (imap_listscan function missing). (Felipe)
Modified: php/php-src/branches/PHP_5_2/ext/standard/basic_functions.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/basic_functions.c 2009-10-05 14:15:15 UTC (rev 289215)
+++ php/php-src/branches/PHP_5_2/ext/standard/basic_functions.c 2009-10-05 14:45:54 UTC (rev 289216)
@@ -4375,6 +4375,9 @@
int ip_len;
unsigned long n;
struct in_addr myaddr;
+#ifdef HAVE_INET_PTON
+ char str[40];
+#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &ip, &ip_len) ==
FAILURE) {
return;
@@ -4383,7 +4386,15 @@
n = strtoul(ip, NULL, 0);
myaddr.s_addr = htonl(n);
+#ifdef HAVE_INET_PTON
+ if (inet_ntop(AF_INET, &myaddr, str, sizeof(str))) {
+ RETURN_STRING(str, 1);
+ } else {
+ RETURN_FALSE;
+ }
+#else
RETURN_STRING(inet_ntoa(myaddr), 1);
+#endif
}
/* }}} */
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2009-10-05 14:15:15 UTC (rev 289215)
+++ php/php-src/branches/PHP_5_3/NEWS 2009-10-05 14:45:54 UTC (rev 289216)
@@ -13,6 +13,8 @@
- Fixed a open_basedir bypass in posix_mkfifo() identified by Grzegorz
Stachowiak. (Rasmus)
+- Fixed bug #49757 (long2ip() can return wrong value in a multi-threaded
+ applications). (Ilia, Florian Anderiasch)
- Fixed bug #49732 (crashes when using fileinfo when timestamp conversion
fails). (Pierre)
- Fixed bug #49698 (Unexpected change in strnatcasecmp()). (Rasmus)
Modified: php/php-src/branches/PHP_5_3/ext/standard/basic_functions.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/basic_functions.c 2009-10-05 14:15:15 UTC (rev 289215)
+++ php/php-src/branches/PHP_5_3/ext/standard/basic_functions.c 2009-10-05 14:45:54 UTC (rev 289216)
@@ -3932,6 +3932,9 @@
int ip_len;
unsigned long n;
struct in_addr myaddr;
+#ifdef HAVE_INET_PTON
+ char str[40];
+#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &ip, &ip_len) ==
FAILURE) {
return;
@@ -3940,7 +3943,15 @@
n = strtoul(ip, NULL, 0);
myaddr.s_addr = htonl(n);
+#ifdef HAVE_INET_PTON
+ if (inet_ntop(AF_INET, &myaddr, str, sizeof(str))) {
+ RETURN_STRING(str, 1);
+ } else {
+ RETURN_FALSE;
+ }
+#else
RETURN_STRING(inet_ntoa(myaddr), 1);
+#endif
}
/* }}} */
Modified: php/php-src/trunk/ext/standard/basic_functions.c
===================================================================
--- php/php-src/trunk/ext/standard/basic_functions.c 2009-10-05 14:15:15 UTC (rev 289215)
+++ php/php-src/trunk/ext/standard/basic_functions.c 2009-10-05 14:45:54 UTC (rev 289216)
@@ -3923,6 +3923,9 @@
int ip_len;
unsigned long n;
struct in_addr myaddr;
+#ifdef HAVE_INET_PTON
+ char str[40];
+#endif
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &ip, &ip_len) ==
FAILURE) {
return;
@@ -3931,7 +3934,15 @@
n = strtoul(ip, NULL, 0);
myaddr.s_addr = htonl(n);
+#ifdef HAVE_INET_PTON
+ if (inet_ntop(AF_INET, &myaddr, str, sizeof(str))) {
+ RETURN_RT_STRING(str, ZSTR_DUPLICATE);
+ } else {
+ RETURN_FALSE;
+ }
+#else
RETURN_RT_STRING(inet_ntoa(myaddr), ZSTR_DUPLICATE);
+#endif
}
/* }}} */