ntdll: Return STATUS_INFO_LENGTH_MISMATCH when len is too small in NtQueryObject(ObjectBasicInformation).

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50791
Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gijs Vermeulen 2021-04-16 20:34:39 +02:00 committed by Alexandre Julliard
parent 250072f91e
commit 749f8c25e2
2 changed files with 16 additions and 1 deletions

View File

@ -1379,6 +1379,7 @@ static void test_query_object(void)
char buffer[1024];
NTSTATUS status;
ULONG len, expected_len;
OBJECT_BASIC_INFORMATION info;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING path, target, *str;
char dir[MAX_PATH], tmp_path[MAX_PATH], file1[MAX_PATH + 16];
@ -1390,6 +1391,20 @@ static void test_query_object(void)
handle = CreateEventA( NULL, FALSE, FALSE, "test_event" );
status = pNtQueryObject( handle, ObjectBasicInformation, NULL, 0, NULL );
ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status );
status = pNtQueryObject( handle, ObjectBasicInformation, &info, 0, NULL );
ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status );
status = pNtQueryObject( handle, ObjectBasicInformation, NULL, 0, &len );
ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status );
len = 0;
status = pNtQueryObject( handle, ObjectBasicInformation, &info, sizeof(OBJECT_BASIC_INFORMATION), &len );
ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status );
ok( len >= sizeof(OBJECT_BASIC_INFORMATION), "unexpected len %u\n", len );
len = 0;
status = pNtQueryObject( handle, ObjectNameInformation, buffer, 0, &len );
ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status );

View File

@ -6734,7 +6734,7 @@ NTSTATUS WINAPI NtQueryObject( HANDLE handle, OBJECT_INFORMATION_CLASS info_clas
{
OBJECT_BASIC_INFORMATION *p = ptr;
if (len < sizeof(*p)) return STATUS_INVALID_BUFFER_SIZE;
if (len < sizeof(*p)) return STATUS_INFO_LENGTH_MISMATCH;
SERVER_START_REQ( get_object_info )
{