ws2_32: Reimplement inet_pton on top of ntdll functions.
And add a test to show that inet_pton does not accept hexadecimal IPv4 addresses, and another test to demonstrate that it has the same leading double colon bug as RtlIpv6StringToAddress. Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f21b25ae8e
commit
41e9a8c5fb
|
@ -18262,7 +18262,6 @@ for ac_func in \
|
|||
inet_addr \
|
||||
inet_network \
|
||||
inet_ntop \
|
||||
inet_pton \
|
||||
|
||||
do :
|
||||
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
|
|
|
@ -2247,7 +2247,6 @@ AC_CHECK_FUNCS(\
|
|||
inet_addr \
|
||||
inet_network \
|
||||
inet_ntop \
|
||||
inet_pton \
|
||||
)
|
||||
|
||||
dnl Check for clock_gettime which may be in -lrt
|
||||
|
|
|
@ -8394,10 +8394,10 @@ PCSTR WINAPI WS_inet_ntop( INT family, PVOID addr, PSTR buffer, SIZE_T len )
|
|||
/***********************************************************************
|
||||
* inet_pton (WS2_32.@)
|
||||
*/
|
||||
INT WINAPI WS_inet_pton( INT family, PCSTR addr, PVOID buffer)
|
||||
INT WINAPI WS_inet_pton(INT family, const char *addr, void *buffer)
|
||||
{
|
||||
#ifdef HAVE_INET_PTON
|
||||
int unixaf, ret;
|
||||
NTSTATUS status;
|
||||
const char *terminator;
|
||||
|
||||
TRACE("family %d, addr %s, buffer (%p)\n", family, debugstr_a(addr), buffer);
|
||||
|
||||
|
@ -8407,21 +8407,20 @@ INT WINAPI WS_inet_pton( INT family, PCSTR addr, PVOID buffer)
|
|||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
unixaf = convert_af_w2u(family);
|
||||
if (unixaf != AF_INET && unixaf != AF_INET6)
|
||||
switch (family)
|
||||
{
|
||||
case WS_AF_INET:
|
||||
status = RtlIpv4StringToAddressA(addr, TRUE, &terminator, buffer);
|
||||
break;
|
||||
case WS_AF_INET6:
|
||||
status = RtlIpv6StringToAddressA(addr, &terminator, buffer);
|
||||
break;
|
||||
default:
|
||||
SetLastError(WSAEAFNOSUPPORT);
|
||||
return SOCKET_ERROR;
|
||||
}
|
||||
|
||||
ret = inet_pton(unixaf, addr, buffer);
|
||||
if (ret == -1) SetLastError(wsaErrno());
|
||||
return ret;
|
||||
#else
|
||||
FIXME( "not supported on this platform\n" );
|
||||
SetLastError( WSAEAFNOSUPPORT );
|
||||
return SOCKET_ERROR;
|
||||
#endif
|
||||
return (status == STATUS_SUCCESS && *terminator == 0);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
|
|
@ -4993,7 +4993,11 @@ static void test_inet_pton(void)
|
|||
"\x20\x01\xcd\xba\x00\x00\x00\x00\x00\x00\x00\x00\x32\x57\x96\x52"},
|
||||
{AF_INET6, 1, 0,
|
||||
"2001:cdba:0:0:0:0:3257:9652", "2001:cdba::3257:9652",
|
||||
"\x20\x01\xcd\xba\x00\x00\x00\x00\x00\x00\x00\x00\x32\x57\x96\x52"}
|
||||
"\x20\x01\xcd\xba\x00\x00\x00\x00\x00\x00\x00\x00\x32\x57\x96\x52"},
|
||||
{AF_INET, 0, 0,
|
||||
"0x12345678", NULL, NULL},
|
||||
{AF_INET6, 0, 0, /* windows bug */
|
||||
"::1:2:3:4:5:6:7", NULL, NULL},
|
||||
};
|
||||
int i, ret;
|
||||
DWORD err;
|
||||
|
|
|
@ -308,9 +308,6 @@
|
|||
/* Define to 1 if you have the `inet_ntop' function. */
|
||||
#undef HAVE_INET_NTOP
|
||||
|
||||
/* Define to 1 if you have the `inet_pton' function. */
|
||||
#undef HAVE_INET_PTON
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
|
|
Loading…
Reference in New Issue