ntdll: Don't return STATUS_BUFFER_OVERFLOW if the buffer is too small to hold one entry.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2022-04-12 22:00:49 -05:00 committed by Alexandre Julliard
parent 0c7dcd9088
commit 4b57ae1674
2 changed files with 5 additions and 6 deletions

View File

@ -2530,7 +2530,7 @@ static void test_query_directory(void)
context = 0xdeadbeef;
size = 0xdeadbeef;
status = NtQueryDirectoryObject( dir, info, 0, TRUE, TRUE, &context, &size );
todo_wine ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx\n", status );
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 );
@ -2630,9 +2630,9 @@ static void test_query_directory(void)
size = 0xdeadbeef;
context = 0xdeadbeef;
status = NtQueryDirectoryObject( dir, info, 0, TRUE, TRUE, &context, &size );
todo_wine ok( status == STATUS_BUFFER_TOO_SMALL, "got %#lx\n", status );
ok( status == STATUS_BUFFER_TOO_SMALL, "got %#lx\n", status );
ok( context == 0xdeadbeef, "got context %#lx\n", context );
todo_wine ok( size == needed_size, "expected size %lu, got %lu\n", needed_size, size );
ok( size == needed_size, "expected size %lu, got %lu\n", needed_size, size );
size = 0xdeadbeef;
memset( buffer, 0xcc, sizeof(buffer) );

View File

@ -1104,13 +1104,12 @@ NTSTATUS WINAPI NtQueryDirectoryObject( HANDLE handle, DIRECTORY_BASIC_INFORMATI
if (single_entry)
{
if (size <= sizeof(*buffer) + 2 * sizeof(WCHAR)) return STATUS_BUFFER_OVERFLOW;
SERVER_START_REQ( get_directory_entry )
{
req->handle = wine_server_obj_handle( handle );
req->index = index;
wine_server_set_reply( req, buffer + 1, size - sizeof(*buffer) - 2*sizeof(WCHAR) );
if (size >= sizeof(*buffer) + 2 * sizeof(WCHAR))
wine_server_set_reply( req, buffer + 1, size - sizeof(*buffer) - 2 * sizeof(WCHAR) );
if (!(ret = wine_server_call( req )))
{
buffer->ObjectName.Buffer = (WCHAR *)(buffer + 1);