[PATCH v2 2/4] ntdll: Don't return STATUS_BUFFER_OVERFLOW if the buffer is too small to hold one entry.
Zebediah Figura
zfigura at codeweavers.com
Tue Apr 12 22:00:49 CDT 2022
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
dlls/ntdll/tests/om.c | 6 +++---
dlls/ntdll/unix/sync.c | 5 ++---
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/dlls/ntdll/tests/om.c b/dlls/ntdll/tests/om.c
index 7d7b4b09e73..89cd2b8e3f4 100644
--- a/dlls/ntdll/tests/om.c
+++ b/dlls/ntdll/tests/om.c
@@ -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) );
diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c
index 46facdd2b0e..efbe363c210 100644
--- a/dlls/ntdll/unix/sync.c
+++ b/dlls/ntdll/unix/sync.c
@@ -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);
--
2.34.1
More information about the wine-devel
mailing list