Commit 689c45b9 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ntdll: Do not return STATUS_SUCCESS on failure in NtQueryObject().

parent 6dc12cdb
......@@ -95,18 +95,20 @@ NTSTATUS WINAPI NtQueryObject(IN HANDLE handle,
if (!(status = server_get_unix_name( handle, &unix_name )))
{
UNICODE_STRING nt_name;
NTSTATUS status;
if (!(status = wine_unix_to_nt_file_name( &unix_name, &nt_name )))
{
if (sizeof(*p) + nt_name.MaximumLength <= len)
if (len < sizeof(*p))
status = STATUS_INFO_LENGTH_MISMATCH;
else if (len < sizeof(*p) + nt_name.MaximumLength)
status = STATUS_BUFFER_OVERFLOW;
else
{
p->Name.Buffer = (WCHAR *)(p + 1);
p->Name.Length = nt_name.Length;
p->Name.MaximumLength = nt_name.MaximumLength;
memcpy( p->Name.Buffer, nt_name.Buffer, nt_name.MaximumLength );
}
else status = STATUS_INFO_LENGTH_MISMATCH;
if (used_len) *used_len = sizeof(*p) + nt_name.MaximumLength;
RtlFreeUnicodeString( &nt_name );
}
......
......@@ -661,7 +661,7 @@ static void test_query_object(void)
HANDLE handle;
char buffer[1024];
NTSTATUS status;
ULONG len;
ULONG len, expected_len;
UNICODE_STRING *str;
char dir[MAX_PATH];
......@@ -713,10 +713,26 @@ static void test_query_object(void)
ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status );
ok( len > sizeof(UNICODE_STRING), "unexpected len %u\n", len );
str = (UNICODE_STRING *)buffer;
ok( sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR) == len ||
broken(sizeof(UNICODE_STRING) + str->Length == len), /* NT4 */
expected_len = sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR);
ok( len == expected_len || broken(len == expected_len - sizeof(WCHAR)), /* NT4 */
"unexpected len %u\n", len );
trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len );
len = 0;
status = pNtQueryObject( handle, ObjectNameInformation, buffer, 0, &len );
ok( status == STATUS_INFO_LENGTH_MISMATCH || broken(status == STATUS_INSUFFICIENT_RESOURCES),
"NtQueryObject failed %x\n", status );
ok( len == expected_len || broken(!len || len == sizeof(UNICODE_STRING)),
"unexpected len %u\n", len );
len = 0;
status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(UNICODE_STRING), &len );
ok( status == STATUS_BUFFER_OVERFLOW || broken(status == STATUS_INSUFFICIENT_RESOURCES
|| status == STATUS_INFO_LENGTH_MISMATCH),
"NtQueryObject failed %x\n", status );
ok( len == expected_len || broken(!len),
"unexpected len %u\n", len );
pNtClose( handle );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment