Fix wrong DACL memory size on Windows (createWindowsDACL) #10712
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The function
createWindowsDACL
incorrectly calculates the memory allocation size for the DACL.Each
AddAccessAllowedAce
call should correspond to asizeof(ACCESS_ALLOWED_ACE)
plus theGetLengthSid
of the SID being used, ensuring sufficient space in the ACL for each entry. However, the original code mistakenly includes only two instances ofsizeof(ACCESS_ALLOWED_ACE)
in the size calculation, although there are three instances ofGetLengthSid
in the sum and there are up to threeAddAccessAllowedAce
calls when theWITH_XC_SSHAGENT
compilation flag is defined.This change corrects the DACL memory allocation calculation to accurately account for all potential
AddAccessAllowedAce
calls by conditionally including the thirdsizeof(ACCESS_ALLOWED_ACE)
. This ensures correct memory allocation across all configurations.Fixes #10713
Testing strategy
manual test.
Type of change