Skip to content

Commit

Permalink
Correct Error Handling When /CopyDomain Processes Corrupt ACL
Browse files Browse the repository at this point in the history
- Address error handling in /CopyDomain where a corrupt ACL could cause a crash due to SetEntriesInAcl() returning an invalid pointer.
- Updated and signed binaries for 1.10.0.3.
  • Loading branch information
NoMoreFood committed Mar 5, 2019
1 parent d0029d9 commit 746027f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
Binary file modified Build/Release/x64/repacls.exe
Binary file not shown.
Binary file modified Build/Release/x86/repacls.exe
Binary file not shown.
Binary file modified Build/Repacls.zip
Binary file not shown.
24 changes: 18 additions & 6 deletions OperationCopyDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,33 @@ bool OperationCopyDomain::ProcessAclAction(WCHAR * const sSdPart, ObjectEntry &

// special case since SetEntriesInAcl does not handle setting both success
// and failure types together
PACL tNewDacl;
PACL tNewDacl = NULL;
DWORD iError = 0;
if (CheckBitSet(tEa.grfAccessMode, SET_AUDIT_SUCCESS) &&
CheckBitSet(tEa.grfAccessMode, SET_AUDIT_FAILURE))
{
PACL tNewDaclTmp;
PACL tNewDaclTmp = NULL;
tEa.grfAccessMode = SET_AUDIT_SUCCESS;
SetEntriesInAcl(1, &tEa, tCurrentAcl, &tNewDaclTmp);
iError = SetEntriesInAcl(1, &tEa, tCurrentAcl, &tNewDaclTmp);
tEa.grfAccessMode = SET_AUDIT_FAILURE;
SetEntriesInAcl(1, &tEa, tNewDaclTmp, &tNewDacl);
LocalFree(tNewDaclTmp);
if (iError == ERROR_SUCCESS) {
SetEntriesInAcl(1, &tEa, tNewDaclTmp, &tNewDacl);
LocalFree(tNewDaclTmp);
}
}
else
{
// merge the new trustee into the dacl
SetEntriesInAcl(1, &tEa, tCurrentAcl, &tNewDacl);
iError = SetEntriesInAcl(1, &tEa, tCurrentAcl, &tNewDacl);
}

// verify the new acl could be generated
if (iError != ERROR_SUCCESS || tNewDacl == NULL)
{
std::wstring sTargetAccountName = GetNameFromSid(tTargetAccountSid);
InputOutput::AddError(L"Could not add '" + sTargetAccountName + L"' for domain '"
+ sTargetDomain + L"' to access control list (" + std::to_wstring(iError) + L").", sSdPart);
continue;
}

// see if the old and new acl match
Expand Down
4 changes: 2 additions & 2 deletions Version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once

#define VERSION_STRING "1.10.0.2"
#define VERSION_COMMA 1,10,0,2
#define VERSION_STRING "1.10.0.3"
#define VERSION_COMMA 1,10,0,3

0 comments on commit 746027f

Please sign in to comment.