Commit f21b25ae authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

ws2_32: Set WSAEINVAL in InetPtonW if the address string is unparsable.

parent 4cb95848
...@@ -8450,6 +8450,7 @@ INT WINAPI InetPtonW(INT family, PCWSTR addr, PVOID buffer) ...@@ -8450,6 +8450,7 @@ INT WINAPI InetPtonW(INT family, PCWSTR addr, PVOID buffer)
WideCharToMultiByte(CP_ACP, 0, addr, -1, addrA, len, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, addr, -1, addrA, len, NULL, NULL);
ret = WS_inet_pton(family, addrA, buffer); ret = WS_inet_pton(family, addrA, buffer);
if (!ret) SetLastError(WSAEINVAL);
HeapFree(GetProcessHeap(), 0, addrA); HeapFree(GetProcessHeap(), 0, addrA);
return ret; return ret;
......
...@@ -5014,11 +5014,11 @@ static void test_inet_pton(void) ...@@ -5014,11 +5014,11 @@ static void test_inet_pton(void)
WSASetLastError(0xdeadbeef); WSASetLastError(0xdeadbeef);
ret = pInetPtonA(tests[i].family, tests[i].printable, buffer); 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); ok (ret == tests[i].ret, "Test [%d]: Expected %d, got %d\n", i, tests[i].ret, ret);
err = WSAGetLastError();
if (tests[i].ret == -1) 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); 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; if (tests[i].ret != 1) continue;
ok (memcmp(buffer, tests[i].raw_data, ok (memcmp(buffer, tests[i].raw_data,
tests[i].family == AF_INET ? sizeof(struct in_addr) : sizeof(struct in6_addr)) == 0, tests[i].family == AF_INET ? sizeof(struct in_addr) : sizeof(struct in6_addr)) == 0,
...@@ -5041,11 +5041,14 @@ static void test_inet_pton(void) ...@@ -5041,11 +5041,14 @@ static void test_inet_pton(void)
WSASetLastError(0xdeadbeef); WSASetLastError(0xdeadbeef);
ret = pInetPtonW(tests[i].family, tests[i].printable ? printableW : NULL, buffer); 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); ok(ret == tests[i].ret, "Test [%d]: Expected %d, got %d\n", i, tests[i].ret, ret);
err = WSAGetLastError();
if (tests[i].ret == -1) 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); 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; if (tests[i].ret != 1) continue;
ok(memcmp(buffer, tests[i].raw_data, ok(memcmp(buffer, tests[i].raw_data,
tests[i].family == AF_INET ? sizeof(struct in_addr) : sizeof(struct in6_addr)) == 0, tests[i].family == AF_INET ? sizeof(struct in_addr) : sizeof(struct in6_addr)) == 0,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment