From 8352d224d458d86949fd9148dd33332f50a25c7f Mon Sep 17 00:00:00 2001 From: Dieter Baron Date: Tue, 17 Dec 2024 11:31:15 +0100 Subject: [PATCH] Check for existance of GetSecurityInfo instead of using partition defines. Adresses issue #473 --- CMakeLists.txt | 1 + config.h.in | 1 + lib/zip_source_file_win32_named.c | 24 ++++++------------------ 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97272bb46..457025a9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,6 +122,7 @@ check_function_exists(fileno HAVE_FILENO) check_function_exists(fseeko HAVE_FSEEKO) check_function_exists(ftello HAVE_FTELLO) check_function_exists(getprogname HAVE_GETPROGNAME) +check_function_exists(GetSecurityInfo HAVE_GETSECURITYINFO) check_symbol_exists(localtime_r time.h HAVE_LOCALTIME_R) check_symbol_exists(localtime_s time.h HAVE_LOCALTIME_S) check_function_exists(memcpy_s HAVE_MEMCPY_S) diff --git a/config.h.in b/config.h.in index 09d42384d..07242da63 100644 --- a/config.h.in +++ b/config.h.in @@ -32,6 +32,7 @@ #cmakedefine HAVE_FSEEKO #cmakedefine HAVE_FTELLO #cmakedefine HAVE_GETPROGNAME +#cmakedefine HAVE_GETSECURITYINFO #cmakedefine HAVE_GNUTLS #cmakedefine HAVE_LIBBZ2 #cmakedefine HAVE_LIBLZMA diff --git a/lib/zip_source_file_win32_named.c b/lib/zip_source_file_win32_named.c index 811174205..5219d6ac2 100644 --- a/lib/zip_source_file_win32_named.c +++ b/lib/zip_source_file_win32_named.c @@ -33,13 +33,6 @@ #include "zip_source_file_win32.h" -/* ACL is not available when targeting the games API partition */ -#if defined(WINAPI_FAMILY_PARTITION) && defined(WINAPI_PARTITION_GAMES) -#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_GAMES) -#define ACL_UNSUPPORTED -#endif -#endif - static zip_int64_t _zip_win32_named_op_commit_write(zip_source_file_context_t *ctx); static zip_int64_t _zip_win32_named_op_create_temp_output(zip_source_file_context_t *ctx); static bool _zip_win32_named_op_open(zip_source_file_context_t *ctx); @@ -106,29 +99,24 @@ _zip_win32_named_op_create_temp_output(zip_source_file_context_t *ctx) { zip_uint32_t value, i; HANDLE th = INVALID_HANDLE_VALUE; - PSECURITY_DESCRIPTOR psd = NULL; PSECURITY_ATTRIBUTES psa = NULL; + PSECURITY_DESCRIPTOR psd = NULL; +#ifdef HAVE_GETSECURITYINFO SECURITY_ATTRIBUTES sa; - SECURITY_INFORMATION si; - DWORD success; - PACL dacl = NULL; +#endif char *tempname = NULL; size_t tempname_size = 0; +#ifdef HAVE_GETSECURITYINFO if ((HANDLE)ctx->f != INVALID_HANDLE_VALUE && GetFileType((HANDLE)ctx->f) == FILE_TYPE_DISK) { - si = DACL_SECURITY_INFORMATION | UNPROTECTED_DACL_SECURITY_INFORMATION; - #ifdef ACL_UNSUPPORTED - success = ERROR_NOT_SUPPORTED; - #else - success = GetSecurityInfo((HANDLE)ctx->f, SE_FILE_OBJECT, si, NULL, NULL, &dacl, NULL, &psd); - #endif - if (success == ERROR_SUCCESS) { + if (GetSecurityInfo((HANDLE)ctx->f, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION | UNPROTECTED_DACL_SECURITY_INFORMATION, NULL, NULL, NULL, NULL, &psd) == ERROR_SUCCESS) { sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle = FALSE; sa.lpSecurityDescriptor = psd; psa = &sa; } } +#endif #ifndef MS_UWP value = GetTickCount();