pajoye                                   Fri, 09 Oct 2009 17:41:29 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=289436

Log:
- Merge: long2ip() can return wrong value in a multi-threaded applications

Changed paths:
    U   php/php-src/branches/PHP_5_3_1/ext/standard/basic_functions.c

Modified: php/php-src/branches/PHP_5_3_1/ext/standard/basic_functions.c
===================================================================
--- php/php-src/branches/PHP_5_3_1/ext/standard/basic_functions.c       
2009-10-09 17:38:19 UTC (rev 289435)
+++ php/php-src/branches/PHP_5_3_1/ext/standard/basic_functions.c       
2009-10-09 17:41:29 UTC (rev 289436)
@@ -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
 }
 /* }}} */


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

Reply via email to