Added test for RtlIpv4StringToAddressExA.

This commit is contained in:
Sebastian Lackner 2014-12-20 20:13:49 +01:00
parent 0d1d699881
commit 030275f110
4 changed files with 148 additions and 2 deletions

1
debian/changelog vendored
View File

@ -12,6 +12,7 @@ wine-staging (1.7.34) UNRELEASED; urgency=low
* Added patch for ID3DXEffect::FindNextValidTechnique.
* Added patch with stub for D3DXComputeTangentFrameEx.
* Added patch with stub for D3DXIntersect.
* Added test for RtlIpv4StringToAddressExA.
* Removed patch to implement combase HSTRING objects (accepted upstream).
* Removed patch to add fake ProductId to registry (accepted upstream).
* Removed patch to implement stubs for MFStartup and MFShutdown (accepted upstream).

View File

@ -77,6 +77,7 @@ PATCHLIST := \
ntdll-NtQuerySection.ok \
ntdll-NtSetLdtEntries.ok \
ntdll-Pipe_SpecialCharacters.ok \
ntdll-RtlIpv4StringToAddressExA.ok \
ntdll-ThreadTime.ok \
ntdll-User_Shared_Data.ok \
ntdll-WRITECOPY.ok \
@ -1155,6 +1156,18 @@ ntdll-Pipe_SpecialCharacters.ok:
echo '+ { "Michael Müller", "ntdll: Allow special characters in pipe names.", 1 },'; \
) > ntdll-Pipe_SpecialCharacters.ok
# Patchset ntdll-RtlIpv4StringToAddressExA
# |
# | Modified files:
# | * dlls/ntdll/tests/rtl.c
# |
.INTERMEDIATE: ntdll-RtlIpv4StringToAddressExA.ok
ntdll-RtlIpv4StringToAddressExA.ok:
$(call APPLY_FILE,ntdll-RtlIpv4StringToAddressExA/0001-ntdll-tests-Add-tests-for-RtlIpv4StringToAddressExA.patch)
@( \
echo '+ { "Sebastian Lackner", "ntdll/tests: Add tests for RtlIpv4StringToAddressExA.", 1 },'; \
) > ntdll-RtlIpv4StringToAddressExA.ok
# Patchset ntdll-ThreadTime
# |
# | This patchset fixes the following Wine bugs:

View File

@ -770,8 +770,7 @@ index e8eb04a..3ddb76a 100644
START_TEST(rtl)
{
InitFunctionPtrs();
@@ -1625,4 +2362,7 @@ START_TEST(rtl)
test_RtlIpv4StringToAddress();
@@ -1626,3 +2363,6 @@ START_TEST(rtl)
test_LdrAddRefDll();
test_LdrLockLoaderLock();
+ test_RtlGetCompressionWorkSpaceSize();

View File

@ -0,0 +1,133 @@
From 83f6efa0d3001beb6b4b3ba4f510502ebeae9bb3 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 20 Dec 2014 20:08:31 +0100
Subject: ntdll/tests: Add tests for RtlIpv4StringToAddressExA.
---
dlls/ntdll/tests/rtl.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 91 insertions(+)
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c
index e8eb04a..d51588c 100644
--- a/dlls/ntdll/tests/rtl.c
+++ b/dlls/ntdll/tests/rtl.c
@@ -89,6 +89,7 @@ static IMAGE_BASE_RELOCATION *(WINAPI *pLdrProcessRelocationBlock)(void*,UINT,US
static CHAR * (WINAPI *pRtlIpv4AddressToStringA)(const IN_ADDR *, LPSTR);
static NTSTATUS (WINAPI *pRtlIpv4AddressToStringExA)(const IN_ADDR *, USHORT, LPSTR, PULONG);
static NTSTATUS (WINAPI *pRtlIpv4StringToAddressA)(PCSTR, BOOLEAN, PCSTR *, IN_ADDR *);
+static NTSTATUS (WINAPI *pRtlIpv4StringToAddressExA)(PCSTR, BOOLEAN, IN_ADDR *, PUSHORT);
static NTSTATUS (WINAPI *pLdrAddRefDll)(ULONG, HMODULE);
static NTSTATUS (WINAPI *pLdrLockLoaderLock)(ULONG, ULONG*, ULONG_PTR*);
static NTSTATUS (WINAPI *pLdrUnlockLoaderLock)(ULONG, ULONG_PTR);
@@ -136,6 +137,7 @@ static void InitFunctionPtrs(void)
pRtlIpv4AddressToStringA = (void *)GetProcAddress(hntdll, "RtlIpv4AddressToStringA");
pRtlIpv4AddressToStringExA = (void *)GetProcAddress(hntdll, "RtlIpv4AddressToStringExA");
pRtlIpv4StringToAddressA = (void *)GetProcAddress(hntdll, "RtlIpv4StringToAddressA");
+ pRtlIpv4StringToAddressExA = (void *)GetProcAddress(hntdll, "RtlIpv4StringToAddressExA");
pLdrAddRefDll = (void *)GetProcAddress(hntdll, "LdrAddRefDll");
pLdrLockLoaderLock = (void *)GetProcAddress(hntdll, "LdrLockLoaderLock");
pLdrUnlockLoaderLock = (void *)GetProcAddress(hntdll, "LdrUnlockLoaderLock");
@@ -1492,6 +1494,94 @@ static void test_RtlIpv4StringToAddress(void)
}
}
+static void test_RtlIpv4StringToAddressEx(void)
+{
+ NTSTATUS res;
+ IN_ADDR ip, expected_ip;
+ USHORT port;
+ struct
+ {
+ PCSTR address;
+ NTSTATUS res;
+ int ip[4];
+ USHORT port;
+ } tests[] =
+ {
+ { "", STATUS_INVALID_PARAMETER, { -1 }, 0xdead },
+ { " ", STATUS_INVALID_PARAMETER, { -1 }, 0xdead },
+ { "1.1.1.1:", STATUS_INVALID_PARAMETER, { 1, 1, 1, 1 }, 0xdead },
+ { "1.1.1.1+", STATUS_INVALID_PARAMETER, { 1, 1, 1, 1 }, 0xdead },
+ { "1.1.1.1:1", STATUS_SUCCESS, { 1, 1, 1, 1 }, 0x100 },
+ { "0.0.0.0:0", STATUS_INVALID_PARAMETER, { 0, 0, 0, 0 }, 0xdead },
+ { "0.0.0.0:1", STATUS_SUCCESS, { 0, 0, 0, 0 }, 0x100 },
+ { "1.2.3.4:65535", STATUS_SUCCESS, { 1, 2, 3, 4 }, 65535 },
+ { "1.2.3.4:65536", STATUS_INVALID_PARAMETER, { 1, 2, 3, 4 }, 0xdead },
+ { "1.2.3.4:0xffff", STATUS_SUCCESS, { 1, 2, 3, 4 }, 65535 },
+ { "1.2.3.4:0XfFfF", STATUS_SUCCESS, { 1, 2, 3, 4 }, 65535 },
+ { "1.2.3.4:011064", STATUS_SUCCESS, { 1, 2, 3, 4 }, 0x3412 },
+ { "1.2.3.4:1234a", STATUS_INVALID_PARAMETER, { 1, 2, 3, 4 }, 0xdead },
+ { "1.2.3.4:1234+", STATUS_INVALID_PARAMETER, { 1, 2, 3, 4 }, 0xdead },
+ { "1.2.3.4: 1234", STATUS_INVALID_PARAMETER, { 1, 2, 3, 4 }, 0xdead },
+ { "1.2.3.4:\t1234", STATUS_INVALID_PARAMETER, { 1, 2, 3, 4 }, 0xdead },
+ };
+ const int testcount = sizeof(tests) / sizeof(tests[0]);
+ int i, Strict;
+
+ if (!pRtlIpv4StringToAddressExA)
+ {
+ skip("RtlIpv4StringToAddressEx not available\n");
+ return;
+ }
+
+ /* do not crash, and do not touch the ip / port. */
+ ip.S_un.S_addr = 0xabababab;
+ port = 0xdead;
+ res = pRtlIpv4StringToAddressExA(NULL, FALSE, &ip, &port);
+ ok(res == STATUS_INVALID_PARAMETER, "[null address] res = 0x%08x, expected 0x%08x\n", res, STATUS_INVALID_PARAMETER);
+ ok(ip.S_un.S_addr == 0xabababab, "RtlIpv4StringToAddressExA should not touch the ip!, ip == %x\n", ip.S_un.S_addr);
+ ok(port == 0xdead, "RtlIpv4StringToAddressExA should not touch the port!, port == %x\n", port);
+
+ port = 0xdead;
+ res = pRtlIpv4StringToAddressExA("1.1.1.1", FALSE, NULL, &port);
+ ok(res == STATUS_INVALID_PARAMETER, "[null ip] res = 0x%08x, expected 0x%08x\n", res, STATUS_INVALID_PARAMETER);
+ ok(port == 0xdead, "RtlIpv4StringToAddressExA should not touch the port!, port == %x\n", port);
+
+ ip.S_un.S_addr = 0xabababab;
+ port = 0xdead;
+ res = pRtlIpv4StringToAddressExA("1.1.1.1", FALSE, &ip, NULL);
+ ok(res == STATUS_INVALID_PARAMETER, "[null port] res = 0x%08x, expected 0x%08x\n", res, STATUS_INVALID_PARAMETER);
+ ok(ip.S_un.S_addr == 0xabababab, "RtlIpv4StringToAddressExA should not touch the ip!, ip == %x\n", ip.S_un.S_addr);
+ ok(port == 0xdead, "RtlIpv4StringToAddressExA should not touch the port!, port == %x\n", port);
+
+ for (i = 0; i < testcount; i++)
+ {
+ /* Strict is only relevant for the ip address, so make sure that it does not influence the port */
+ for (Strict = 0; Strict < 2; Strict++)
+ {
+ ip.S_un.S_addr = 0xabababab;
+ port = 0xdead;
+ res = pRtlIpv4StringToAddressExA(tests[i].address, Strict, &ip, &port);
+ if (tests[i].ip[0] == -1)
+ {
+ expected_ip.S_un.S_addr = 0xabababab;
+ }
+ else
+ {
+ expected_ip.S_un.S_un_b.s_b1 = tests[i].ip[0];
+ expected_ip.S_un.S_un_b.s_b2 = tests[i].ip[1];
+ expected_ip.S_un.S_un_b.s_b3 = tests[i].ip[2];
+ expected_ip.S_un.S_un_b.s_b4 = tests[i].ip[3];
+ }
+ ok(res == tests[i].res, "[%s] res = 0x%08x, expected 0x%08x\n",
+ tests[i].address, res, tests[i].res);
+ ok(ip.S_un.S_addr == expected_ip.S_un.S_addr, "[%s] ip = %08x, expected %08x\n",
+ tests[i].address, ip.S_un.S_addr, expected_ip.S_un.S_addr);
+ ok(port == tests[i].port, "[%s] port = %u, expected %u\n",
+ tests[i].address, port, tests[i].port);
+ }
+ }
+}
+
static void test_LdrAddRefDll(void)
{
HMODULE mod, mod2;
@@ -1624,4 +1714,5 @@ START_TEST(rtl)
test_RtlIpv4AddressToStringEx();
test_RtlIpv4StringToAddress();
+ test_RtlIpv4StringToAddressEx();
test_LdrAddRefDll();
test_LdrLockLoaderLock();
--
2.1.3