[NTOS:SE] Fix handling of relative security descriptors in SeQuerySecurityDescriptorInfo

This commit is contained in:
Timo Kreuzer 2020-01-03 20:44:05 +01:00
parent dab6b26a57
commit 274bc4de1c

View file

@ -658,28 +658,32 @@ SeQuerySecurityDescriptorInfo(
/* Calculate the required security descriptor length */ /* Calculate the required security descriptor length */
Control = SE_SELF_RELATIVE; Control = SE_SELF_RELATIVE;
if ((*SecurityInformation & OWNER_SECURITY_INFORMATION) && if (*SecurityInformation & OWNER_SECURITY_INFORMATION)
(ObjectSd->Owner != NULL))
{ {
Owner = (PSID)((ULONG_PTR)ObjectSd->Owner + (ULONG_PTR)ObjectSd); Owner = SepGetOwnerFromDescriptor(ObjectSd);
OwnerLength = ROUND_UP(RtlLengthSid(Owner), 4); if (Owner != NULL)
Control |= (ObjectSd->Control & SE_OWNER_DEFAULTED); {
OwnerLength = ROUND_UP(RtlLengthSid(Owner), 4);
Control |= (ObjectSd->Control & SE_OWNER_DEFAULTED);
}
} }
if ((*SecurityInformation & GROUP_SECURITY_INFORMATION) && if (*SecurityInformation & GROUP_SECURITY_INFORMATION)
(ObjectSd->Group != NULL))
{ {
Group = (PSID)((ULONG_PTR)ObjectSd->Group + (ULONG_PTR)ObjectSd); Group = SepGetGroupFromDescriptor(ObjectSd);
GroupLength = ROUND_UP(RtlLengthSid(Group), 4); if (Group != NULL)
Control |= (ObjectSd->Control & SE_GROUP_DEFAULTED); {
GroupLength = ROUND_UP(RtlLengthSid(Group), 4);
Control |= (ObjectSd->Control & SE_GROUP_DEFAULTED);
}
} }
if ((*SecurityInformation & DACL_SECURITY_INFORMATION) && if ((*SecurityInformation & DACL_SECURITY_INFORMATION) &&
(ObjectSd->Control & SE_DACL_PRESENT)) (ObjectSd->Control & SE_DACL_PRESENT))
{ {
if (ObjectSd->Dacl != NULL) Dacl = SepGetDaclFromDescriptor(ObjectSd);
if (Dacl != NULL)
{ {
Dacl = (PACL)((ULONG_PTR)ObjectSd->Dacl + (ULONG_PTR)ObjectSd);
DaclLength = ROUND_UP((ULONG)Dacl->AclSize, 4); DaclLength = ROUND_UP((ULONG)Dacl->AclSize, 4);
} }
@ -689,9 +693,9 @@ SeQuerySecurityDescriptorInfo(
if ((*SecurityInformation & SACL_SECURITY_INFORMATION) && if ((*SecurityInformation & SACL_SECURITY_INFORMATION) &&
(ObjectSd->Control & SE_SACL_PRESENT)) (ObjectSd->Control & SE_SACL_PRESENT))
{ {
if (ObjectSd->Sacl != NULL) Sacl = SepGetSaclFromDescriptor(ObjectSd);
if (Sacl != NULL)
{ {
Sacl = (PACL)((ULONG_PTR)ObjectSd->Sacl + (ULONG_PTR)ObjectSd);
SaclLength = ROUND_UP(Sacl->AclSize, 4); SaclLength = ROUND_UP(Sacl->AclSize, 4);
} }