diff --git a/dlls/ntdll/tests/rtlstr.c b/dlls/ntdll/tests/rtlstr.c index 5239de0..cb9a95d 100644 --- a/dlls/ntdll/tests/rtlstr.c +++ b/dlls/ntdll/tests/rtlstr.c @@ -233,15 +233,18 @@ static void test_RtlInitUnicodeStringEx(void) ok(result == STATUS_NAME_TOO_LONG, "pRtlInitUnicodeStringEx(&uni, 0) returns %x, expected %x\n", result, STATUS_NAME_TOO_LONG); - ok(uni.Length == 12345, - "pRtlInitUnicodeStringEx(&uni, 0) sets Length to %u, expected %u\n", - uni.Length, 12345); - ok(uni.MaximumLength == 12345, - "pRtlInitUnicodeStringEx(&uni, 0) sets MaximumLength to %u, expected %u\n", - uni.MaximumLength, 12345); - ok(uni.Buffer == (void *) 0xdeadbeef, - "pRtlInitUnicodeStringEx(&uni, 0) sets Buffer to %p, expected %x\n", - uni.Buffer, 0xdeadbeef); + ok(uni.Length == 12345 || + uni.Length == 0, /* win2k3 */ + "pRtlInitUnicodeStringEx(&uni, 0) sets Length to %u, expected 12345 or 0\n", + uni.Length); + ok(uni.MaximumLength == 12345 || + uni.MaximumLength == 0, /* win2k3 */ + "pRtlInitUnicodeStringEx(&uni, 0) sets MaximumLength to %u, expected 12345 or 0\n", + uni.MaximumLength); + ok(uni.Buffer == (void *) 0xdeadbeef || + uni.Buffer == teststring2, /* win2k3 */ + "pRtlInitUnicodeStringEx(&uni, 0) sets Buffer to %p, expected %x or %p\n", + uni.Buffer, 0xdeadbeef, teststring2); uni.Length = 12345; uni.MaximumLength = 12345; @@ -1477,8 +1480,6 @@ static const int2str_t int2str[] = { { 2, 1000, 10, 33, "1111101000\0------------------------", STATUS_SUCCESS}, { 2, 10000, 14, 33, "10011100010000\0--------------------", STATUS_SUCCESS}, { 2, 32767, 15, 33, "111111111111111\0-------------------", STATUS_SUCCESS}, - { 2, 32768, 16, 33, "1000000000000000\0------------------", STATUS_SUCCESS}, - { 2, 65535, 16, 33, "1111111111111111\0------------------", STATUS_SUCCESS}, { 2, 65536, 17, 33, "10000000000000000\0-----------------", STATUS_SUCCESS}, { 2, 100000, 17, 33, "11000011010100000\0-----------------", STATUS_SUCCESS}, { 2, 1000000, 20, 33, "11110100001001000000\0--------------", STATUS_SUCCESS}, @@ -1531,9 +1532,6 @@ static const int2str_t int2str[] = { {16, 2147483649U, 8, 9, "80000001\0--------------------------", STATUS_SUCCESS}, {16, 4294967294U, 8, 9, "FFFFFFFE\0--------------------------", STATUS_SUCCESS}, {16, 4294967295U, 8, 9, "FFFFFFFF\0--------------------------", STATUS_SUCCESS}, /* max unsigned int */ - - { 2, 32768, 16, 17, "1000000000000000\0------------------", STATUS_SUCCESS}, - { 2, 32768, 16, 16, "1000000000000000-------------------", STATUS_SUCCESS}, { 2, 65536, 17, 18, "10000000000000000\0-----------------", STATUS_SUCCESS}, { 2, 65536, 17, 17, "10000000000000000------------------", STATUS_SUCCESS}, { 2, 131072, 18, 19, "100000000000000000\0----------------", STATUS_SUCCESS}, @@ -1618,10 +1616,92 @@ static void one_RtlIntegerToUnicodeString_test(int test_num, const int2str_t *in static void test_RtlIntegerToUnicodeString(void) { + WCHAR str_Buffer[STRI_BUFFER_LENGTH + 1]; + UNICODE_STRING unicode_string; + NTSTATUS result; size_t test_num; + static const WCHAR test_32[] = { + '1','0','0','0','0','0','0','0','0','0','0','0','0','0','0','0'}; + static const WCHAR test_33[] = { + '1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1'}; + static const WCHAR nochange[] = { + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-', + '-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-','-',}; + for (test_num = 0; test_num < NB_INT2STR; test_num++) one_RtlIntegerToUnicodeString_test(test_num, &int2str[test_num]); + + /* extra characters (indeterminate) added after number */ + memcpy(str_Buffer, nochange, sizeof(nochange)); + unicode_string.Length = 0; + unicode_string.MaximumLength = 33 * sizeof(WCHAR); + unicode_string.Buffer = str_Buffer; + result = pRtlIntegerToUnicodeString(32768, 2, &unicode_string); + ok(result == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", result); + ok(unicode_string.Buffer[unicode_string.Length/sizeof(WCHAR)] == '\0', + "RtlIntegerToUnicodeString(32768, 2, [out]) is not NULL terminated\n"); + ok(memcmp(unicode_string.Buffer, test_32, sizeof(test_32)) == 0, + "RtlIntegerToUnicodeString(32768, 2, [out]) output does not match\n"); + ok(unicode_string.Length >= 32, + "RtlIntegerToUnicodeString(32768, 2, [out]) string has Length %d, expected >= 32\n", + unicode_string.Length); + ok(unicode_string.MaximumLength == 66, + "RtlIntegerToUnicodeString(32768, 2, [out]) string has MaximumLength %d, expected: 66\n", + unicode_string.MaximumLength); + + /* extra characters (indeterminate) added after number */ + memcpy(str_Buffer, nochange, sizeof(nochange)); + unicode_string.Length = 0; + unicode_string.MaximumLength = 33 * sizeof(WCHAR); + unicode_string.Buffer = str_Buffer; + result = pRtlIntegerToUnicodeString(65535, 2, &unicode_string); + ok(result == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", result); + ok(unicode_string.Buffer[unicode_string.Length/sizeof(WCHAR)] == '\0', + "RtlIntegerToUnicodeString(65535, 2, [out]) is not NULL terminated\n"); + ok(memcmp(unicode_string.Buffer, test_33, sizeof(test_33)) == 0, + "RtlIntegerToUnicodeString(65535, 2, [out]) output does not match\n"); + ok(unicode_string.Length >= 32, + "RtlIntegerToUnicodeString(65535, 2, [out]) string has Length %d, expected >= 32\n", + unicode_string.Length); + ok(unicode_string.MaximumLength == 66, + "RtlIntegerToUnicodeString(65535, 2, [out]) string has MaximumLength %d, expected: 66\n", + unicode_string.MaximumLength); + + /* length does not match (indeterminate) */ + memcpy(str_Buffer, nochange, sizeof(nochange)); + unicode_string.Length = 0; + unicode_string.MaximumLength = 17 * sizeof(WCHAR); + unicode_string.Buffer = str_Buffer; + result = pRtlIntegerToUnicodeString(32768, 2, &unicode_string); + todo_wine + { + ok(result == STATUS_BUFFER_OVERFLOW, "Expected STATUS_BUFFER_OVERFLOW, got %08x\n", result); + ok(memcmp(unicode_string.Buffer, nochange, sizeof(nochange)) == 0, + "RtlIntegerToUnicodeString(32768, 2, [out]) output does not match\n"); + } + ok(unicode_string.Length >= 32, + "RtlIntegerToUnicodeString(32768, 2, [out]) string has Length %d, expected >= 32\n", + unicode_string.Length); + ok(unicode_string.MaximumLength == 34, + "RtlIntegerToUnicodeString(32768, 2, [out]) string has MaximumLength %d, expected: 34\n", + unicode_string.MaximumLength); + + /* length does not match (indeterminate) */ + memcpy(str_Buffer, nochange, sizeof(nochange)); + unicode_string.Length = 0; + unicode_string.MaximumLength = 16 * sizeof(WCHAR); + unicode_string.Buffer = str_Buffer; + result = pRtlIntegerToUnicodeString(32768, 2, &unicode_string); + ok(result == STATUS_BUFFER_OVERFLOW, "Expected STATUS_BUFFER_OVERFLOW, got %08x\n", result); + ok(memcmp(unicode_string.Buffer, nochange, sizeof(nochange)) == 0, + "RtlIntegerToUnicodeString(32768, 2, [out]) output does not match\n"); + ok(unicode_string.Length >= 32, + "RtlIntegerToUnicodeString(32768, 2, [out]) string has Length %d, expected >= 32\n", + unicode_string.Length); + ok(unicode_string.MaximumLength == 32, + "RtlIntegerToUnicodeString(32768, 2, [out]) string has MaximumLength %d, expected: 32\n", + unicode_string.MaximumLength); } -- 1.5.4.3