apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r1081123 - in /apr/apr/branches/1.4.x: CHANGES network_io/unix/sockaddr.c test/testsock.c
Date Sun, 13 Mar 2011 14:16:18 GMT
Author: trawick
Date: Sun Mar 13 14:16:18 2011
New Revision: 1081123

URL: http://svn.apache.org/viewvc?rev=1081123&view=rev
Log:
apr_sockaddr_info_get() on AIX: Fix a problem which could set
the port field in the native socket address to 1 when 0 was
specified.

An AIX-specific hack to work around a service name limitation
used "1" as the service name, but the 1 was not replaced later.

PR: 46964

Modified:
    apr/apr/branches/1.4.x/CHANGES
    apr/apr/branches/1.4.x/network_io/unix/sockaddr.c
    apr/apr/branches/1.4.x/test/testsock.c

Modified: apr/apr/branches/1.4.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/CHANGES?rev=1081123&r1=1081122&r2=1081123&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.4.x/CHANGES [utf-8] Sun Mar 13 14:16:18 2011
@@ -1,6 +1,10 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.4.3
 
+  *) apr_sockaddr_info_get() on AIX: Fix a problem which could set
+     the port field in the native socket address to 1 when 0 was
+     specified.  PR 46964.  [Jeff Trawick]
+
   *) configure: Make definition of apr_ino_t independent of
      _FILE_OFFSET_BITS even on platforms where ino_t is 'unsigned int'.
      [Stefan Fritsch]

Modified: apr/apr/branches/1.4.x/network_io/unix/sockaddr.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/network_io/unix/sockaddr.c?rev=1081123&r1=1081122&r2=1081123&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/network_io/unix/sockaddr.c (original)
+++ apr/apr/branches/1.4.x/network_io/unix/sockaddr.c Sun Mar 13 14:16:18 2011
@@ -58,6 +58,15 @@ struct apr_ipsubnet_t {
 #define GETHOSTBYNAME_BUFLEN 512
 #endif
 
+#ifdef _AIX
+/* Some levels of AIX getaddrinfo() don't like servname = "0", so
+ * set servname to "1" when port is 0 and fix it up later.
+ */
+#define AIX_SERVNAME_HACK 1
+#else
+#define AIX_SERVNAME_HACK 0
+#endif
+
 #ifdef _WIN32_WCE
 /* XXX: BS solution.  Need an HAVE_GETSERVBYNAME and actually
  * do something here, to provide the obvious proto mappings.
@@ -138,6 +147,11 @@ void apr_sockaddr_vars_set(apr_sockaddr_
         addr->sa.sin.sin_port = htons(port);
         addr->port = port;
     }
+#if AIX_SERVNAME_HACK
+    else {
+        addr->sa.sin.sin_port = htons(port);
+    }
+#endif
 
     if (family == APR_INET) {
         addr->salen = sizeof(struct sockaddr_in);
@@ -331,16 +345,12 @@ static apr_status_t call_resolver(apr_so
         hints.ai_flags |= AI_NUMERICHOST;
 #endif
 #else
-#ifdef _AIX
-        /* But current AIX getaddrinfo() doesn't like servname = "0";
-         * the "1" won't hurt since we use the port parameter to fill
-         * in the returned socket addresses later
-         */
+#if AIX_SERVNAME_HACK
         if (!port) {
             servname = "1";
         }
         else
-#endif /* _AIX */
+#endif /* AIX_SERVNAME_HACK */
         servname = apr_itoa(p, port);
 #endif /* OSF1 */
     }

Modified: apr/apr/branches/1.4.x/test/testsock.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.4.x/test/testsock.c?rev=1081123&r1=1081122&r2=1081123&view=diff
==============================================================================
--- apr/apr/branches/1.4.x/test/testsock.c (original)
+++ apr/apr/branches/1.4.x/test/testsock.c Sun Mar 13 14:16:18 2011
@@ -74,6 +74,12 @@ static void test_addr_info(abts_case *tc
     rv = apr_sockaddr_info_get(&sa, "127.0.0.1", APR_UNSPEC, 80, 0, p);
     APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv);
     ABTS_STR_EQUAL(tc, "127.0.0.1", sa->hostname);
+
+    rv = apr_sockaddr_info_get(&sa, "127.0.0.1", APR_UNSPEC, 0, 0, p);
+    APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv);
+    ABTS_STR_EQUAL(tc, "127.0.0.1", sa->hostname);
+    ABTS_INT_EQUAL(tc, 0, sa->port);
+    ABTS_INT_EQUAL(tc, 0, ntohs(sa->sa.sin.sin_port));
 }
 
 static void test_serv_by_name(abts_case *tc, void *data)



Mime
View raw message