ntdll: Write a null terminator in NtQueryDirectoryObject.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4b57ae1674
commit
1e750b5b44
|
@ -2532,7 +2532,7 @@ static void test_query_directory(void)
|
|||
status = NtQueryDirectoryObject( dir, info, 0, TRUE, TRUE, &context, &size );
|
||||
ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx\n", status );
|
||||
ok( context == 0xdeadbeef, "got context %#lx\n", context );
|
||||
todo_wine ok( size == sizeof(*info) || broken(!size) /* WoW64 */, "got size %lu\n", size );
|
||||
ok( size == sizeof(*info) || broken(!size) /* WoW64 */, "got size %lu\n", size );
|
||||
|
||||
context = 0xdeadbeef;
|
||||
size = 0xdeadbeef;
|
||||
|
@ -2547,7 +2547,7 @@ static void test_query_directory(void)
|
|||
status = NtQueryDirectoryObject( dir, info, sizeof(buffer), TRUE, TRUE, &context, &size );
|
||||
ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx\n", status );
|
||||
ok( context == 0xdeadbeef, "got context %#lx\n", context );
|
||||
todo_wine ok( size == sizeof(*info) || broken(!size) /* WoW64 */, "got size %lu\n", size );
|
||||
ok( size == sizeof(*info) || broken(!size) /* WoW64 */, "got size %lu\n", size );
|
||||
if (size == sizeof(*info))
|
||||
ok( !memcmp( &info[0], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
|
||||
|
||||
|
@ -2600,8 +2600,7 @@ static void test_query_directory(void)
|
|||
}
|
||||
check_unicode_string( &info[0].ObjectName, name1 );
|
||||
check_unicode_string( &info[0].ObjectTypeName, L"Mutant" );
|
||||
todo_wine
|
||||
ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
|
||||
ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
|
||||
|
||||
memset( buffer, 0xcc, sizeof(buffer) );
|
||||
status = NtQueryDirectoryObject( dir, info, sizeof(buffer), TRUE, FALSE, &context, &size );
|
||||
|
@ -2609,13 +2608,13 @@ static void test_query_directory(void)
|
|||
ok( context == 2, "got context %#lx\n", context );
|
||||
check_unicode_string( &info[0].ObjectName, name2 );
|
||||
check_unicode_string( &info[0].ObjectTypeName, L"Mutant" );
|
||||
todo_wine ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
|
||||
ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
|
||||
|
||||
size = 0xdeadbeef;
|
||||
status = NtQueryDirectoryObject( dir, info, sizeof(buffer), TRUE, FALSE, &context, &size );
|
||||
ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx\n", status );
|
||||
ok( context == 2, "got context %#lx\n", context );
|
||||
todo_wine ok( size == sizeof(*info) || broken(!size) /* WoW64 */, "got size %lu\n", size );
|
||||
ok( size == sizeof(*info) || broken(!size) /* WoW64 */, "got size %lu\n", size );
|
||||
|
||||
memset( buffer, 0xcc, sizeof(buffer) );
|
||||
status = NtQueryDirectoryObject( dir, info, sizeof(buffer), TRUE, TRUE, &context, &size );
|
||||
|
@ -2623,7 +2622,7 @@ static void test_query_directory(void)
|
|||
ok( context == 1, "got context %#lx\n", context );
|
||||
check_unicode_string( &info[0].ObjectName, name1 );
|
||||
check_unicode_string( &info[0].ObjectTypeName, L"Mutant" );
|
||||
todo_wine ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
|
||||
ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
|
||||
|
||||
needed_size = size;
|
||||
|
||||
|
@ -2650,7 +2649,7 @@ static void test_query_directory(void)
|
|||
ok( context == 1, "got context %#lx\n", context );
|
||||
check_unicode_string( &info[0].ObjectName, name1 );
|
||||
check_unicode_string( &info[0].ObjectTypeName, L"Mutant" );
|
||||
todo_wine ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
|
||||
ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
|
||||
|
||||
memset( buffer, 0xcc, sizeof(buffer) );
|
||||
status = NtQueryDirectoryObject( dir, info, sizeof(buffer), FALSE, TRUE, &context, &size );
|
||||
|
|
|
@ -1108,14 +1108,14 @@ NTSTATUS WINAPI NtQueryDirectoryObject( HANDLE handle, DIRECTORY_BASIC_INFORMATI
|
|||
{
|
||||
req->handle = wine_server_obj_handle( handle );
|
||||
req->index = index;
|
||||
if (size >= sizeof(*buffer) + 2 * sizeof(WCHAR))
|
||||
wine_server_set_reply( req, buffer + 1, size - sizeof(*buffer) - 2 * sizeof(WCHAR) );
|
||||
if (size >= 2 * sizeof(*buffer) + 2 * sizeof(WCHAR))
|
||||
wine_server_set_reply( req, buffer + 2, size - 2 * sizeof(*buffer) - 2 * sizeof(WCHAR) );
|
||||
if (!(ret = wine_server_call( req )))
|
||||
{
|
||||
buffer->ObjectName.Buffer = (WCHAR *)(buffer + 1);
|
||||
buffer->ObjectName.Buffer = (WCHAR *)(buffer + 2);
|
||||
buffer->ObjectName.Length = reply->name_len;
|
||||
buffer->ObjectName.MaximumLength = reply->name_len + sizeof(WCHAR);
|
||||
buffer->ObjectTypeName.Buffer = (WCHAR *)(buffer + 1) + reply->name_len/sizeof(WCHAR) + 1;
|
||||
buffer->ObjectTypeName.Buffer = (WCHAR *)(buffer + 2) + reply->name_len/sizeof(WCHAR) + 1;
|
||||
buffer->ObjectTypeName.Length = wine_server_reply_size( reply ) - reply->name_len;
|
||||
buffer->ObjectTypeName.MaximumLength = buffer->ObjectTypeName.Length + sizeof(WCHAR);
|
||||
/* make room for the terminating null */
|
||||
|
@ -1123,11 +1123,20 @@ NTSTATUS WINAPI NtQueryDirectoryObject( HANDLE handle, DIRECTORY_BASIC_INFORMATI
|
|||
buffer->ObjectTypeName.Length );
|
||||
buffer->ObjectName.Buffer[buffer->ObjectName.Length/sizeof(WCHAR)] = 0;
|
||||
buffer->ObjectTypeName.Buffer[buffer->ObjectTypeName.Length/sizeof(WCHAR)] = 0;
|
||||
|
||||
memset( &buffer[1], 0, sizeof(buffer[1]) );
|
||||
|
||||
*context = index + 1;
|
||||
}
|
||||
else if (ret == STATUS_NO_MORE_ENTRIES)
|
||||
{
|
||||
if (size > sizeof(*buffer))
|
||||
memset( buffer, 0, sizeof(*buffer) );
|
||||
if (ret_size) *ret_size = sizeof(*buffer);
|
||||
}
|
||||
|
||||
if (ret_size && (!ret || ret == STATUS_BUFFER_TOO_SMALL))
|
||||
*ret_size = sizeof(*buffer) + reply->total_len + 2 * sizeof(WCHAR);
|
||||
*ret_size = 2 * sizeof(*buffer) + reply->total_len + 2 * sizeof(WCHAR);
|
||||
}
|
||||
SERVER_END_REQ;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue