From e7aa09276e184e40cc67a5292de5db8ac2874bc0 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Tue, 21 May 2024 11:17:43 +0200 Subject: [PATCH] Fix wrong DACL memory size on Windows (createWindowsDACL) (#10712) Each AddAccessAllowedAce invocation should be matched with a corresponding sizeof(ACCESS_ALLOWED_ACE) and the respective GetLengthSid of the SID being used. This ensures that there is enough space in the ACL for each entry. The issue manifest itself only when WITH_XC_SSHAGENT is defined. --- src/core/Bootstrap.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/Bootstrap.cpp b/src/core/Bootstrap.cpp index 739e3446fb..4c3458cc67 100644 --- a/src/core/Bootstrap.cpp +++ b/src/core/Bootstrap.cpp @@ -180,7 +180,8 @@ namespace Bootstrap // Calculate the amount of memory that must be allocated for the DACL cbACL = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(pTokenUser->User.Sid) - + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(pLocalSystemSid) + GetLengthSid(pOwnerRightsSid); + + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(pLocalSystemSid) + sizeof(ACCESS_ALLOWED_ACE) + + GetLengthSid(pOwnerRightsSid); // Create and initialize an ACL pACL = static_cast(HeapAlloc(GetProcessHeap(), 0, cbACL));