Skip to content

Commit

Permalink
Check for existance of GetSecurityInfo instead of using partition def…
Browse files Browse the repository at this point in the history
…ines.

Adresses issue #473
  • Loading branch information
dillof committed Dec 17, 2024
1 parent 6ba97d4 commit 8352d22
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 6 additions & 18 deletions lib/zip_source_file_win32_named.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 8352d22

Please sign in to comment.