Signed-off-by: Mohamad Al-Jaf mohamadaljaf@gmail.com --- dlls/kernel32/tests/Makefile.in | 1 + dlls/kernel32/tests/security.c | 71 +++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 dlls/kernel32/tests/security.c
diff --git a/dlls/kernel32/tests/Makefile.in b/dlls/kernel32/tests/Makefile.in index db106ab9fc9..517a9e27f09 100644 --- a/dlls/kernel32/tests/Makefile.in +++ b/dlls/kernel32/tests/Makefile.in @@ -31,6 +31,7 @@ SOURCES = \ profile.c \ resource.c \ resource.rc \ + security.c \ sync.c \ thread.c \ time.c \ diff --git a/dlls/kernel32/tests/security.c b/dlls/kernel32/tests/security.c new file mode 100644 index 00000000000..ef6c703406e --- /dev/null +++ b/dlls/kernel32/tests/security.c @@ -0,0 +1,71 @@ +/* + * Unit tests for security functions + * + * Copyright (c) 2022 Mohamad Al-Jaf + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "wine/test.h" + +static HMODULE hdll; +static HANDLE (WINAPI *pCreateBoundaryDescriptorA)(LPCSTR,ULONG); + +static BOOL init_function_pointers(void) +{ + hdll = GetModuleHandleA("kernel32.dll"); + + if (hdll) + { + pCreateBoundaryDescriptorA = (void *)GetProcAddress(hdll, "CreateBoundaryDescriptorA"); + return TRUE; + } + + return FALSE; +} + +void test_CreateBoundaryDescriptorA(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 = pCreateBoundaryDescriptorA(NULL, 0); + ok(res == NULL, "expected NULL pointer\n"); + + res = pCreateBoundaryDescriptorA(buffer, 0); + todo_wine + ok(res != NULL, "expected HANDLE to boundary descriptor\n"); + + SetLastError(0xdeadbeef); + res = pCreateBoundaryDescriptorA(overload, 0); + error = GetLastError(); + ok(res == NULL && (error == ERROR_FILENAME_EXCED_RANGE), "expected name to exceed MAX_PATH\n"); +} + +START_TEST(security) +{ + if (init_function_pointers()) + { + test_CreateBoundaryDescriptorA(); + FreeLibrary(hdll); + } + else + skip("could not load kernel32.dll\n"); +}