Signed-off-by: Alex Henrie <alexhenrie24(a)gmail.com>
---
v2:
- Modify two tests and add three more to show that if the last
component starts with "0x", it's not actually a 32-bit IPv4 address,
it's still just a 16-bit IPv6 component.
- Add four tests to show that values starting with 0x are always capped
at 0x7FFFFFFF.
- Add a test for an invalid IPv4 addresses followed by a period.
- Correct the flags on a test case that should succeed with the non-Ex
function but fail on the Ex function, although it fails on non-Ex on XP
and Vista.
(I didn't notice the first two problems before because the first version
of my fuzzer program didn't generate any strings that included the
letter "x".)
---
dlls/ntdll/tests/rtl.c | 64 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c
index 559a7d625c..445f3538d8 100644
--- a/dlls/ntdll/tests/rtl.c
+++ b/dlls/ntdll/tests/rtl.c
@@ -1539,6 +1539,8 @@ static const struct
{ 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0, 0x8888 } },
{ "1111:2222:3333:4444:5555:6666::7777:8888", STATUS_SUCCESS, 35,
{ 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0, 0x7777 }, ex_fail_6 },
+ { "1111:2222:3333:4444:5555:6666:7777::8888", STATUS_SUCCESS, 36,
+ { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0 }, ex_fail_6|win_broken_6 },
{ "1111:2222:3333:4444:5555::", STATUS_SUCCESS, 26,
{ 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0 } },
{ "1111:2222:3333:4444:5555::123.123.123.123", STATUS_SUCCESS, 41,
@@ -1555,8 +1557,30 @@ static const struct
{ 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0x8800 }, ex_fail_6 },
{ "1111:2222:3333:4444:5555::0x8888", STATUS_SUCCESS, 27,
{ 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0x8888 }, ex_fail_6 },
+ { "1111:2222:3333:4444:5555::0x80000000", STATUS_SUCCESS, 27,
+ { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0, 0, 0xffff }, ex_fail_6 },
+ { "1111:2222:3333:4444::5555:0x012345678", STATUS_SUCCESS, 27,
+ { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0, 0x5555, 0x7856 }, ex_fail_6 },
+ { "1111:2222:3333:4444::5555:0x123456789", STATUS_SUCCESS, 27,
+ { 0x1111, 0x2222, 0x3333, 0x4444, 0, 0, 0x5555, 0xffff }, ex_fail_6 },
+ { "1111:2222:3333:4444:5555:6666:0x12345678", STATUS_INVALID_PARAMETER, 31,
+ { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0xabab, 0xabab }, ex_fail_6 },
+ { "1111:2222:3333:4444:5555:6666:7777:0x80000000", STATUS_SUCCESS, 36,
+ { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0xffff }, ex_fail_6 },
+ { "1111:2222:3333:4444:5555:6666:7777:0x012345678", STATUS_SUCCESS, 36,
+ { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x7856 }, ex_fail_6 },
+ { "1111:2222:3333:4444:5555:6666:7777:0x123456789", STATUS_SUCCESS, 36,
+ { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0xffff }, ex_fail_6 },
+ { "111:222:333:444:555:666:777:0x123456789abcdef0", STATUS_SUCCESS, 29,
+ { 0x1101, 0x2202, 0x3303, 0x4404, 0x5505, 0x6606, 0x7707, 0xffff }, ex_fail_6 },
{ "1111:2222:3333:4444:5555::08888", STATUS_INVALID_PARAMETER, 31,
{ 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0xabab, 0xabab, 0xabab } },
+ { "1111:2222:3333:4444:5555::08888::", STATUS_INVALID_PARAMETER, 31,
+ { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0xabab, 0xabab, 0xabab } },
+ { "1111:2222:3333:4444:5555:6666:7777:fffff:", STATUS_INVALID_PARAMETER, 40,
+ { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0xabab } },
+ { "1111:2222:3333:4444:5555:6666::fffff:", STATUS_INVALID_PARAMETER, 36,
+ { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0xabab, 0xabab } },
{ "1111:2222:3333:4444:5555::fffff", STATUS_INVALID_PARAMETER, 31,
{ 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0xabab, 0xabab, 0xabab } },
{ "1111:2222:3333:4444::fffff", STATUS_INVALID_PARAMETER, 26,
@@ -1672,16 +1696,24 @@ static const struct
{ -1 } },
{ "1111", STATUS_INVALID_PARAMETER, 4,
{ -1 } },
+ { "0x1111", STATUS_INVALID_PARAMETER, 1,
+ { -1 } },
{ "1111:22223333:4444:5555:6666:1.2.3.4", STATUS_INVALID_PARAMETER, -1,
{ 0x1111, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
{ "1111:22223333:4444:5555:6666:7777:8888", STATUS_INVALID_PARAMETER, -1,
{ 0x1111, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
+ { "1111:123456789:4444:5555:6666:7777:8888", STATUS_INVALID_PARAMETER, -1,
+ { 0x1111, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
+ { "1111:1234567890abcdef0:4444:5555:6666:7777:888", STATUS_INVALID_PARAMETER, -1,
+ { 0x1111, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
{ "1111:2222:", STATUS_INVALID_PARAMETER, 10,
{ 0x1111, 0x2222, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
{ "1111:2222:1.2.3.4", STATUS_INVALID_PARAMETER, 17,
{ 0x1111, 0x2222, 0x201, 0xab03, 0xabab, 0xabab, 0xabab, 0xabab } },
{ "1111:2222:3333", STATUS_INVALID_PARAMETER, 14,
{ 0x1111, 0x2222, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
+ { "1111:2222:3333:4444:5555:6666::1.2.3.4", STATUS_SUCCESS, 32,
+ { 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0, 0x100 }, ex_fail_6 },
{ "1111:2222:3333:4444:5555:6666:7777:1.2.3.4", STATUS_SUCCESS, 36,
{ 0x1111, 0x2222, 0x3333, 0x4444, 0x5555, 0x6666, 0x7777, 0x100 }, ex_fail_6 },
{ "1111:2222:3333:4444:5555:6666:7777:8888:", STATUS_SUCCESS, 39,
@@ -1702,12 +1734,30 @@ static const struct
{ 0x1111, 0, 0, 0, 0, 0, 0, 0x3333 }, ex_fail_6 },
{ "12345::6:7:8", STATUS_INVALID_PARAMETER, -1,
{ -1 } },
+ { "1::001.2.3.4", STATUS_SUCCESS, 12,
+ { 0x100, 0, 0, 0, 0, 0, 0x201, 0x403 } },
+ { "1::1.002.3.4", STATUS_SUCCESS, 12,
+ { 0x100, 0, 0, 0, 0, 0, 0x201, 0x403 } },
+ { "1::0001.2.3.4", STATUS_INVALID_PARAMETER, -1,
+ { 0x100, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
+ { "1::1.0002.3.4", STATUS_INVALID_PARAMETER, -1,
+ { 0x100, 0xab01, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
{ "1::1.2.256.4", STATUS_INVALID_PARAMETER, -1,
{ 0x100, 0x201, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
+ { "1::1.2.4294967296.4", STATUS_INVALID_PARAMETER, -1,
+ { 0x100, 0x201, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
+ { "1::1.2.18446744073709551616.4", STATUS_INVALID_PARAMETER, -1,
+ { 0x100, 0x201, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
{ "1::1.2.3.256", STATUS_INVALID_PARAMETER, 12,
{ 0x100, 0x201, 0xab03, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
+ { "1::1.2.3.4294967296", STATUS_INVALID_PARAMETER, 19,
+ { 0x100, 0x201, 0xab03, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
+ { "1::1.2.3.18446744073709551616", STATUS_INVALID_PARAMETER, 29,
+ { 0x100, 0x201, 0xab03, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
{ "1::1.2.3.300", STATUS_INVALID_PARAMETER, 12,
{ 0x100, 0x201, 0xab03, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
+ { "1::1.2.3.300.", STATUS_INVALID_PARAMETER, 12,
+ { 0x100, 0x201, 0xab03, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
{ "1::1.2::1", STATUS_INVALID_PARAMETER, 6,
{ 0x100, 0xab01, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
{ "1::1.2.3.4::1", STATUS_SUCCESS, 10,
@@ -1758,6 +1808,20 @@ static const struct
{ -1 } },
{ "::-1", STATUS_SUCCESS, 2,
{ 0, 0, 0, 0, 0, 0, 0, 0 }, ex_fail_6 },
+ { "::12345678", STATUS_INVALID_PARAMETER, 10,
+ { 0, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
+ { "::123456789", STATUS_INVALID_PARAMETER, 11,
+ { 0, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
+ { "::1234567890abcdef0", STATUS_INVALID_PARAMETER, 19,
+ { 0, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab, 0xabab } },
+ { "::0x80000000", STATUS_SUCCESS, 3,
+ { 0, 0, 0, 0, 0, 0, 0, 0xffff }, ex_fail_6 },
+ { "::0x012345678", STATUS_SUCCESS, 3,
+ { 0, 0, 0, 0, 0, 0, 0, 0x7856 }, ex_fail_6 },
+ { "::0x123456789", STATUS_SUCCESS, 3,
+ { 0, 0, 0, 0, 0, 0, 0, 0xffff }, ex_fail_6 },
+ { "::0x1234567890abcdef0", STATUS_SUCCESS, 3,
+ { 0, 0, 0, 0, 0, 0, 0, 0xffff }, ex_fail_6 },
{ "::.", STATUS_SUCCESS, 2,
{ 0, 0, 0, 0, 0, 0, 0, 0 }, ex_fail_6 },
{ "::..", STATUS_SUCCESS, 2,
--
2.25.1