VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/libzip/zip_source_file_win32_named.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/libzip/zip_source_file_win32_named.c')
-rw-r--r--src/Common/libzip/zip_source_file_win32_named.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/Common/libzip/zip_source_file_win32_named.c b/src/Common/libzip/zip_source_file_win32_named.c
index 855e605a..ae72db19 100644
--- a/src/Common/libzip/zip_source_file_win32_named.c
+++ b/src/Common/libzip/zip_source_file_win32_named.c
@@ -1,6 +1,6 @@
/*
zip_source_file_win32_named.c -- source for Windows file opened by name
- Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
@@ -33,6 +33,13 @@
#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);
@@ -110,7 +117,11 @@ _zip_win32_named_op_create_temp_output(zip_source_file_context_t *ctx) {
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) {
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = FALSE;
@@ -210,8 +221,20 @@ _zip_win32_named_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t
st->regular_file = false;
if (file_attributes.dwFileAttributes != INVALID_FILE_ATTRIBUTES) {
- if ((file_attributes.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE | FILE_ATTRIBUTE_REPARSE_POINT)) == 0) {
- st->regular_file = true;
+ if ((file_attributes.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0) {
+ if (file_attributes.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
+#ifdef IO_REPARSE_TAG_DEDUP // Not defined in WinSDK 7.1 or before (VS2010).
+ WIN32_FIND_DATA find_data;
+ /* Deduplication on Windows replaces files with reparse points;
+ * accept them as regular files. */
+ if (file_ops->find_first_file(ctx->fname, &find_data) != INVALID_HANDLE_VALUE) {
+ st->regular_file = (find_data.dwReserved0 == IO_REPARSE_TAG_DEDUP);
+ }
+#endif
+ }
+ else {
+ st->regular_file = true;
+ }
}
}