Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45656 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42834 invoked from network); 3 Oct 2009 16:40:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Oct 2009 16:40:43 -0000 Authentication-Results: pb1.pair.com header.from=ml@anderiasch.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=ml@anderiasch.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain anderiasch.de from 81.169.138.148 cause and error) X-PHP-List-Original-Sender: ml@anderiasch.de X-Host-Fingerprint: 81.169.138.148 ares.art-core.org Received: from [81.169.138.148] ([81.169.138.148:57581] helo=mail.anderiasch.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 07/44-17798-98E77CA4 for ; Sat, 03 Oct 2009 12:40:42 -0400 Received: from [172.16.0.83] (p4FE64C37.dip.t-dialin.net [79.230.76.55]) by mail.anderiasch.de (Postfix) with ESMTPSA id 38E5412550A7 for ; Sat, 3 Oct 2009 18:40:38 +0200 (CEST) Message-ID: <4AC77E69.4010501@anderiasch.de> Date: Sat, 03 Oct 2009 18:40:09 +0200 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.8.1.23) Gecko/20090812 Lightning/0.9 Thunderbird/2.0.0.23 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: internals@lists.php.net Content-Type: multipart/mixed; boundary="------------090806070108050903040602" Subject: Patch for Bug #49757 From: ml@anderiasch.de (Florian Anderiasch) --------------090806070108050903040602 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hello, I've tried to fix http://bugs.php.net/bug.php?id=49757 As it's my first patch in c, any reviews and suggestions would be very welcome. Greetings, Florian --------------090806070108050903040602 Content-Type: text/plain; name="svn_diff_5_3" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="svn_diff_5_3" Index: ext/standard/basic_functions.c =================================================================== --- ext/standard/basic_functions.c (revision 289129) +++ ext/standard/basic_functions.c (working copy) @@ -3932,6 +3932,7 @@ int ip_len; unsigned long n; struct in_addr myaddr; + char str[INET_ADDRSTRLEN]; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &ip, &ip_len) == FAILURE) { return; @@ -3940,7 +3941,14 @@ n = strtoul(ip, NULL, 0); myaddr.s_addr = htonl(n); - RETURN_STRING(inet_ntoa(myaddr), 1); + +#ifdef HAVE_INET_NTOP + inet_ntop(AF_INET, &myaddr, str, INET_ADDRSTRLEN); +#else + str = inet_ntoa(myaddr); +#endif + + RETURN_STRING(str, 1); } /* }}} */ Index: ext/standard/basic_functions.h =================================================================== --- ext/standard/basic_functions.h (revision 289129) +++ ext/standard/basic_functions.h (working copy) @@ -59,6 +59,7 @@ #endif PHP_FUNCTION(ip2long); PHP_FUNCTION(long2ip); +#define INET_ADDRSTRLEN 16 /* system functions */ PHP_FUNCTION(getenv); --------------090806070108050903040602 Content-Type: text/plain; name="svn_diff_HEAD" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="svn_diff_HEAD" Index: ext/standard/basic_functions.c =================================================================== --- ext/standard/basic_functions.c (revision 289129) +++ ext/standard/basic_functions.c (working copy) @@ -3923,6 +3923,7 @@ int ip_len; unsigned long n; struct in_addr myaddr; + char str[INET_ADDRSTRLEN]; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &ip, &ip_len) == FAILURE) { return; @@ -3931,7 +3932,14 @@ n = strtoul(ip, NULL, 0); myaddr.s_addr = htonl(n); - RETURN_RT_STRING(inet_ntoa(myaddr), ZSTR_DUPLICATE); + +#ifdef HAVE_INET_NTOP + inet_ntop(AF_INET, &myaddr, str, INET_ADDRSTRLEN); +#else + str = inet_ntoa(myaddr); +#endif + + RETURN_RT_STRING(str, ZSTR_DUPLICATE); } /* }}} */ Index: ext/standard/basic_functions.h =================================================================== --- ext/standard/basic_functions.h (revision 289129) +++ ext/standard/basic_functions.h (working copy) @@ -59,6 +59,7 @@ #endif PHP_FUNCTION(ip2long); PHP_FUNCTION(long2ip); +#define INET_ADDRSTRLEN 16 /* system functions */ PHP_FUNCTION(getenv); --------------090806070108050903040602--