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

Mohamad Al-Jaf mohamadaljaf at gmail.com
Wed Feb 23 00:15:58 CST 2022


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

diff --git a/dlls/kernel32/tests/security.c b/dlls/kernel32/tests/security.c
index b8ae1474a80..1606c08ac8b 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;
     }
 
@@ -83,12 +85,35 @@ void test_CreatePrivateNamespaceA(void)
     ok(res == NULL && (error == ERROR_FILENAME_EXCED_RANGE), "expected prefix to exceed MAX_PATH\n");
 }
 
+void test_OpenPrivateNamespaceA(void)
+{
+    DWORD error;
+    HANDLE res;
+    CHAR buffer[MAX_PATH] = "test";
+    CHAR overload[MAX_PATH + 5] = "";
+
+    for (int i = 0; i < (MAX_PATH + 5); 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(res == NULL && (error == ERROR_FILENAME_EXCED_RANGE), "expected prefix to exceed MAX_PATH\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