Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/utils/WinUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,20 @@ static void ResetRegKeyAcl(HKEY hkey, const char* keyName) {
return;
}
SECURITY_DESCRIPTOR secdesc;
InitializeSecurityDescriptor(&secdesc, SECURITY_DESCRIPTOR_REVISION);
if (!InitializeSecurityDescriptor(&secdesc, SECURITY_DESCRIPTOR_REVISION)) {
RegCloseKey(hKey);
return;
}

#pragma warning(push)
#pragma warning(disable : 6248)
// "Setting a SECURITY_DESCRIPTOR's DACL to nullptr will result in an unprotected object"
// https://docs.microsoft.com/en-us/cpp/code-quality/c6248?view=msvc-170
SetSecurityDescriptorDacl(&secdesc, TRUE, nullptr, TRUE);
#pragma warning(pop)
ACL dacl;
if (!InitializeAcl(&dacl, sizeof(dacl), ACL_REVISION)) {
RegCloseKey(hKey);
return;
}
if (!SetSecurityDescriptorDacl(&secdesc, TRUE, &dacl, FALSE)) {
RegCloseKey(hKey);
return;
}

RegSetKeySecurity(hKey, DACL_SECURITY_INFORMATION, &secdesc);
RegCloseKey(hKey);
Expand Down
Loading