VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2024-11-27 01:04:55 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2024-11-27 01:04:55 +0100
commitc98fc900d8fff99f227fbfe68d59435c78e026c5 (patch)
tree9679af0b3a16fad0b139d7b8b5225ae33d9c1845 /src
parent968b72947f04440a48d38c70e64ee3226e3f1e59 (diff)
downloadVeraCrypt-c98fc900d8fff99f227fbfe68d59435c78e026c5.tar.gz
VeraCrypt-c98fc900d8fff99f227fbfe68d59435c78e026c5.zip
Windows Setup: Fix the implementation of backup/restore of file permission during update
Diffstat (limited to 'src')
-rw-r--r--src/Common/Dlgcode.c16
-rw-r--r--src/Common/Dlgcode.h1
2 files changed, 4 insertions, 13 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 8b1db616..ee3630c0 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -15827,9 +15827,8 @@ BOOL EnableRequiredSetupPrivileges(PPRIVILEGE_STATE currentState)
// Helper function to backup security information
BOOL BackupSecurityInfo(const wchar_t* filePath, PSECURITY_INFO_BACKUP pBackup)
{
BOOL result = FALSE;
- PSECURITY_DESCRIPTOR pSD = NULL;
DWORD dwRes;
ZeroMemory(pBackup, sizeof(SECURITY_INFO_BACKUP));
@@ -15842,20 +15841,17 @@ BOOL BackupSecurityInfo(const wchar_t* filePath, PSECURITY_INFO_BACKUP pBackup)
&pBackup->pOrigOwner,
&pBackup->pOrigGroup,
&pBackup->pOrigDacl,
&pBackup->pOrigSacl,
- &pSD);
+ &pBackup->pOrigSD);
if (dwRes == ERROR_SUCCESS)
{
// The individual pointers (pOrigOwner, etc.) are now valid
// and point to the copied data
result = TRUE;
}
- if (pSD)
- LocalFree(pSD);
-
return result;
}
// Helper function to restore security information
@@ -15890,16 +15886,10 @@ BOOL RestoreSecurityInfo(const wchar_t* filePath, PSECURITY_INFO_BACKUP pBackup)
// Helper function to free security backup
void FreeSecurityBackup(PSECURITY_INFO_BACKUP pBackup)
{
- if (pBackup->pOrigOwner)
- LocalFree(pBackup->pOrigOwner);
- if (pBackup->pOrigGroup)
- LocalFree(pBackup->pOrigGroup);
- if (pBackup->pOrigDacl)
- LocalFree(pBackup->pOrigDacl);
- if (pBackup->pOrigSacl)
- LocalFree(pBackup->pOrigSacl);
+ if (pBackup->pOrigSD)
+ LocalFree(pBackup->pOrigSD);
ZeroMemory(pBackup, sizeof(SECURITY_INFO_BACKUP));
}
// Helper function to take ownership and modify file permissions
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index 2bc95ae9..4dfae20f 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -603,8 +603,9 @@ typedef struct _SECURITY_INFO_BACKUP {
PSID pOrigOwner;
PSID pOrigGroup;
PACL pOrigDacl;
PACL pOrigSacl;
+ PSECURITY_DESCRIPTOR pOrigSD;
} SECURITY_INFO_BACKUP, * PSECURITY_INFO_BACKUP;
typedef struct _PRIVILEGE_STATE {
BOOL takeOwnership;