[PATCH v4 9/9] tests/kernel32: Add MAX_PATH test for OpenPrivateNamespaceA.

Mohamad Al-Jaf mohamadaljaf at gmail.com
Mon Feb 28 01:48:03 CST 2022


Signed-off-by: Mohamad Al-Jaf <mohamadaljaf at gmail.com>
---
 dlls/kernel32/tests/security.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/dlls/kernel32/tests/security.c b/dlls/kernel32/tests/security.c
index 52140994370..794c6256f61 100644
--- a/dlls/kernel32/tests/security.c
+++ b/dlls/kernel32/tests/security.c
@@ -23,6 +23,7 @@
 static HMODULE hdll;
 static HANDLE (WINAPI *pCreateBoundaryDescriptorA)(LPCSTR,ULONG);
 static HANDLE (WINAPI *pCreatePrivateNamespaceA)(LPSECURITY_ATTRIBUTES,LPVOID,LPCSTR);
+static HANDLE (WINAPI *pOpenPrivateNamespaceA)(LPVOID,LPCSTR);
 
 static BOOL init_function_pointers(void)
 {
@@ -32,6 +33,7 @@ static BOOL init_function_pointers(void)
     {
         pCreateBoundaryDescriptorA = (void *)GetProcAddress(hdll, "CreateBoundaryDescriptorA");
         pCreatePrivateNamespaceA = (void *)GetProcAddress(hdll, "CreatePrivateNamespaceA");
+        pOpenPrivateNamespaceA = (void *)GetProcAddress(hdll, "OpenPrivateNamespaceA");
         return TRUE;
     }
 
@@ -86,12 +88,36 @@ void test_CreatePrivateNamespaceA(void)
     ok(res == NULL, "expected NULL pointer\n");
 }
 
+void test_OpenPrivateNamespaceA(void)
+{
+    DWORD error;
+    HANDLE res;
+    CHAR buffer[MAX_PATH] = "test";
+    CHAR overload[MAX_PATH + 100] = "";
+
+    for (int i = 0; i < (MAX_PATH + 100); i++)
+        overload[i] = 't';
+
+    res = pOpenPrivateNamespaceA(NULL, NULL);
+    ok(res == NULL, "expected NULL pointer\n");
+
+    res = pOpenPrivateNamespaceA(NULL, buffer);
+    ok(res == NULL, "expected NULL pointer\n");
+
+    SetLastError(0xdeadbeef);
+    res = pOpenPrivateNamespaceA(NULL, overload);
+    error = GetLastError();
+    ok(error != ERROR_FILENAME_EXCED_RANGE, "expected no MAX_PATH limit in buffer\n");
+    ok(res == NULL, "expected NULL pointer\n");
+}
+
 START_TEST(security)
 {
     if (init_function_pointers())
     {
         test_CreateBoundaryDescriptorA();
         test_CreatePrivateNamespaceA();
+        test_OpenPrivateNamespaceA();
         FreeLibrary(hdll);
     }
     else
-- 
2.35.1




More information about the wine-devel mailing list