curl-functions.m4: verify working RFC 4291 zero prefixed IPv4 - mapped format

Detect incompatible inet_ntop() call for IPv6 output.

Closes #22136
This commit is contained in:
Daniel Stenberg 2026-06-22 16:31:49 +02:00
parent e9a2b0dc72
commit bf5cc6ab8b
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View 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;
]])
],[