]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl-functions.m4: verify working RFC 4291 zero prefixed IPv4 - mapped format
authorDaniel Stenberg <daniel@haxx.se>
Mon, 22 Jun 2026 14:31:49 +0000 (16:31 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 25 Jun 2026 09:02:50 +0000 (11:02 +0200)
Detect incompatible inet_ntop() call for IPv6 output.

Closes #22136

m4/curl-functions.m4

index 3a273770168d987815850d00158477d9e185bbbb..debd76d1d53440f549c80dbfc6cf9b0c123fe678 100644 (file)
@@ -2324,7 +2324,6 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_NTOP], [
         ipv4a[2] = 0x64;
         ipv4a[3] = 0x01;
         ipv4a[4] = 0x01;
-        /* - */
         ipv4ptr = inet_ntop(AF_INET, ipv4a, ipv4res, sizeof(ipv4res));
         if(!ipv4ptr)
           return 1; /* fail */
@@ -2348,7 +2347,6 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_NTOP], [
         ipv6a[14] = 0x76;
         ipv6a[15] = 0xc8;
         ipv6a[25] = 0x01;
-        /* - */
         ipv6ptr = inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res));
         if(!ipv6ptr)
           return 1; /* fail */
@@ -2358,7 +2356,22 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_NTOP], [
           return 1; /* fail */
         if(memcmp(ipv6res, "fe80::214:4fff:fe0b:76c8", 24))
           return 1; /* fail */
-        /* - */
+
+        /* verify working RFC 4291 zero prefixed IPv4 - mapped format */
+        memset(ipv6a, 0, sizeof(ipv6a));
+        ipv6a[12] = 0x7f;
+        ipv6a[13] = 0x0;
+        ipv6a[14] = 0x0;
+        ipv6a[15] = 0x01;
+        ipv6ptr = inet_ntop(AF_INET6, ipv6a, ipv6res, sizeof(ipv6res));
+        if(!ipv6ptr)
+          return 1; /* fail */
+        if(ipv6ptr != ipv6res)
+          return 1; /* fail */
+        if(!ipv6ptr[0])
+          return 1; /* fail */
+        if(memcmp(ipv6res, "::127.0.0.1", 11))
+          return 1; /* fail */
         return 0;
       ]])
     ],[