apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jor...@apache.org
Subject svn commit: r1816628 - in /apr/apr/trunk: include/apr_network_io.h network_io/unix/sockaddr.c test/testsock.c
Date Wed, 29 Nov 2017 13:31:09 GMT
Author: jorton
Date: Wed Nov 29 13:31:09 2017
New Revision: 1816628

URL: http://svn.apache.org/viewvc?rev=1816628&view=rev
Log:
* network_io/unix/sockaddr.c (apr_sockaddr_zone_set): Fail
  for an address which is not link-local.

* include/apr_network_io.h: Document the above.

* test/testsock.c (test_zone): Test for that.

Modified:
    apr/apr/trunk/include/apr_network_io.h
    apr/apr/trunk/network_io/unix/sockaddr.c
    apr/apr/trunk/test/testsock.c

Modified: apr/apr/trunk/include/apr_network_io.h
URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_network_io.h?rev=1816628&r1=1816627&r2=1816628&view=diff
==============================================================================
--- apr/apr/trunk/include/apr_network_io.h (original)
+++ apr/apr/trunk/include/apr_network_io.h Wed Nov 29 13:31:09 2017
@@ -444,6 +444,8 @@ APR_DECLARE(apr_status_t) apr_sockaddr_i
 /* Set the zone of an IPv6 link-local address object.
  * @param sa Socket address object
  * @param zone_id Zone ID (textual "eth0" or numeric "3").
+ * @return Returns APR_EBADIP for non-IPv6 socket or an IPv6 address
+ * which isn't link-local.
  */
 APR_DECLARE(apr_status_t) apr_sockaddr_zone_set(apr_sockaddr_t *sa,
                                                 const char *zone_id);

Modified: apr/apr/trunk/network_io/unix/sockaddr.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/network_io/unix/sockaddr.c?rev=1816628&r1=1816627&r2=1816628&view=diff
==============================================================================
--- apr/apr/trunk/network_io/unix/sockaddr.c (original)
+++ apr/apr/trunk/network_io/unix/sockaddr.c Wed Nov 29 13:31:09 2017
@@ -1225,7 +1225,8 @@ APR_DECLARE(apr_status_t) apr_sockaddr_z
 #else
     unsigned int idx;
     
-    if (sa->family != APR_INET6) {
+    if (sa->family != APR_INET6
+        || !IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)sa->ipaddr_ptr)) {
         return APR_EBADIP;
     }
 

Modified: apr/apr/trunk/test/testsock.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testsock.c?rev=1816628&r1=1816627&r2=1816628&view=diff
==============================================================================
--- apr/apr/trunk/test/testsock.c (original)
+++ apr/apr/trunk/test/testsock.c Wed Nov 29 13:31:09 2017
@@ -660,7 +660,6 @@ static void test_zone(abts_case *tc, voi
     const char *name = NULL;
     apr_uint32_t id = 0;
     
-    /* RFC 5737 address */
     rv = apr_sockaddr_info_get(&sa, "127.0.0.1", APR_INET, 8080, 0, p);
     APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv);
 
@@ -669,6 +668,12 @@ static void test_zone(abts_case *tc, voi
                    apr_sockaddr_zone_set(sa, "1"));
     ABTS_INT_EQUAL(tc, APR_EBADIP,
                    apr_sockaddr_zone_get(sa, &name, &id, p));
+    
+    rv = apr_sockaddr_info_get(&sa, "::1", APR_INET6, 8080, 0, p);
+    APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv);
+
+    /* Fail for an address which isn't link-local */
+    ABTS_INT_EQUAL(tc, APR_EBADIP, apr_sockaddr_zone_set(sa, "1"));
 
     rv = apr_sockaddr_info_get(&sa, TEST_ZONE_ADDR, APR_INET6, 8080, 0, p);
     APR_ASSERT_SUCCESS(tc, "Problem generating sockaddr", rv);



Mime
View raw message