]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix tests when configured with -DOPENSSL_USE_IPV6=0
authorTom Cosgrove <tom.cosgrove@arm.com>
Fri, 9 Sep 2022 06:24:48 +0000 (07:24 +0100)
committerTomas Mraz <tomas@openssl.org>
Mon, 12 Sep 2022 06:28:30 +0000 (08:28 +0200)
In include/internal/sockets.h it says that you can disable IPv6, and only
defines OPENSSL_USE_IPV6 (to 0 or 1) if it's not already defined.

The codebase generally then checks `#if OPENSSL_USE_IPV6`.

However, test_bio_dgram uses `#if defined(OPENSSL_USE_IPV6)` which means it tries
to test IPv6 even if it's explicitly configured out with -DOPENSSL_USE_IPV6=0
(`#if defined(OPENSSL_USE_IPV6)` is always true).

This fixes that.

Change-Id: Ie1641c9dd654f27f3bdca186517df5599ad1059b

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19181)

test/bio_dgram_test.c

index 15731cb6479de8245cd42ead53cd12f2dfddcf31..7f147283b998d107e34760e2a367c4c4a65d9814 100644 (file)
@@ -17,7 +17,7 @@
 static int compare_addr(const BIO_ADDR *a, const BIO_ADDR *b)
 {
     struct in_addr xa, xb;
-#if defined(OPENSSL_USE_IPV6)
+#if OPENSSL_USE_IPV6
     struct in6_addr xa6, xb6;
 #endif
     void *pa, *pb;
@@ -31,7 +31,7 @@ static int compare_addr(const BIO_ADDR *a, const BIO_ADDR *b)
         pb = &xb;
         slen = sizeof(xa);
     }
-#if defined(OPENSSL_USE_IPV6)
+#if OPENSSL_USE_IPV6
     else if (BIO_ADDR_family(a) == AF_INET6) {
         pa = &xa6;
         pb = &xb6;
@@ -103,7 +103,7 @@ static int test_bio_dgram_impl(int af, int use_local)
     BIO_ADDR *addr1 = NULL, *addr2 = NULL, *addr3 = NULL, *addr4 = NULL,
              *addr5 = NULL, *addr6 = NULL;
     struct in_addr ina;
-#if defined(OPENSSL_USE_IPV6)
+#if OPENSSL_USE_IPV6
     struct in6_addr ina6;
 #endif
     void *pina;
@@ -119,7 +119,7 @@ static int test_bio_dgram_impl(int af, int use_local)
         pina = &ina;
         inal = sizeof(ina);
     }
-#if defined(OPENSSL_USE_IPV6)
+#if OPENSSL_USE_IPV6
     else if (af == AF_INET6) {
         TEST_info("# Testing with AF_INET6, local=%d\n", use_local);
         pina = &ina6;
@@ -132,7 +132,9 @@ static int test_bio_dgram_impl(int af, int use_local)
 
     memset(pina, 0, inal);
     ina.s_addr = htonl(0x7f000001UL);
+#if OPENSSL_USE_IPV6
     ina6.s6_addr[15] = 1;
+#endif
 
     addr1 = BIO_ADDR_new();
     if (!TEST_ptr(addr1))
@@ -432,12 +434,12 @@ struct bio_dgram_case {
 static const struct bio_dgram_case bio_dgram_cases[] = {
     /* Test without local */
     { AF_INET,  0 },
-#if defined(OPENSSL_USE_IPV6)
+#if OPENSSL_USE_IPV6
     { AF_INET6, 0 },
 #endif
     /* Test with local */
     { AF_INET,  1 },
-#if defined(OPENSSL_USE_IPV6)
+#if OPENSSL_USE_IPV6
     { AF_INET6, 1 }
 #endif
 };