ws2_32: Set WSAEINVAL in InetPtonW if the address string is unparsable.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4cb95848fd
commit
f21b25ae8e
|
@ -8450,6 +8450,7 @@ INT WINAPI InetPtonW(INT family, PCWSTR addr, PVOID buffer)
|
|||
WideCharToMultiByte(CP_ACP, 0, addr, -1, addrA, len, NULL, NULL);
|
||||
|
||||
ret = WS_inet_pton(family, addrA, buffer);
|
||||
if (!ret) SetLastError(WSAEINVAL);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, addrA);
|
||||
return ret;
|
||||
|
|
|
@ -5014,11 +5014,11 @@ static void test_inet_pton(void)
|
|||
WSASetLastError(0xdeadbeef);
|
||||
ret = pInetPtonA(tests[i].family, tests[i].printable, buffer);
|
||||
ok (ret == tests[i].ret, "Test [%d]: Expected %d, got %d\n", i, tests[i].ret, ret);
|
||||
err = WSAGetLastError();
|
||||
if (tests[i].ret == -1)
|
||||
{
|
||||
err = WSAGetLastError();
|
||||
ok (tests[i].err == err, "Test [%d]: Expected 0x%x, got 0x%x\n", i, tests[i].err, err);
|
||||
}
|
||||
else
|
||||
ok (err == 0xdeadbeef, "Test [%d]: Expected 0xdeadbeef, got 0x%x\n", i, err);
|
||||
if (tests[i].ret != 1) continue;
|
||||
ok (memcmp(buffer, tests[i].raw_data,
|
||||
tests[i].family == AF_INET ? sizeof(struct in_addr) : sizeof(struct in6_addr)) == 0,
|
||||
|
@ -5041,11 +5041,14 @@ static void test_inet_pton(void)
|
|||
WSASetLastError(0xdeadbeef);
|
||||
ret = pInetPtonW(tests[i].family, tests[i].printable ? printableW : NULL, buffer);
|
||||
ok(ret == tests[i].ret, "Test [%d]: Expected %d, got %d\n", i, tests[i].ret, ret);
|
||||
err = WSAGetLastError();
|
||||
if (tests[i].ret == -1)
|
||||
{
|
||||
err = WSAGetLastError();
|
||||
ok(tests[i].err == err, "Test [%d]: Expected 0x%x, got 0x%x\n", i, tests[i].err, err);
|
||||
}
|
||||
else if (tests[i].ret == 0)
|
||||
ok(err == WSAEINVAL || broken(err == 0xdeadbeef) /* win2008 */,
|
||||
"Test [%d]: Expected WSAEINVAL, got 0x%x\n", i, err);
|
||||
else
|
||||
ok(err == 0xdeadbeef, "Test [%d]: Expected 0xdeadbeef, got 0x%x\n", i, err);
|
||||
if (tests[i].ret != 1) continue;
|
||||
ok(memcmp(buffer, tests[i].raw_data,
|
||||
tests[i].family == AF_INET ? sizeof(struct in_addr) : sizeof(struct in6_addr)) == 0,
|
||||
|
|
Loading…
Reference in New Issue