[BASESRV-CSRSRV]

A little bit of code reorganization (more a "matter of taste"; delete allocated pointers in the reverse way we allocated them).

[NTDLL]
- Free a used SID (i.e. fix a memory leak).
- Only just "reserve" memory pages for the section for the CSR port. Memory will be actually committed later on (checked on Windows Server 2003 and on http://j00ru.vexillium.org/?p=527 ).

svn path=/branches/ros-csrss/; revision=58716
This commit is contained in:
Hermès Bélusca-Maïto 2013-04-07 18:28:38 +00:00
parent 463b98e376
commit 74ef4033a2
4 changed files with 29 additions and 36 deletions

View file

@ -221,7 +221,7 @@ CsrpConnectToServer(IN PWSTR ObjectDirectory)
NULL, NULL,
&CsrSectionViewSize, &CsrSectionViewSize,
PAGE_READWRITE, PAGE_READWRITE,
SEC_COMMIT, SEC_RESERVE,
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -278,6 +278,7 @@ CsrpConnectToServer(IN PWSTR ObjectDirectory)
NULL, NULL,
&ConnectionInfo, &ConnectionInfo,
&ConnectionInfoLength); &ConnectionInfoLength);
RtlFreeSid(SystemSid);
NtClose(CsrSectionHandle); NtClose(CsrSectionHandle);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {

View file

@ -203,8 +203,8 @@ CreateBaseAcls(OUT PACL* Dacl,
/* Allocate one ACL with 3 ACEs each for one SID */ /* Allocate one ACL with 3 ACEs each for one SID */
AclLength = sizeof(ACL) + 3 * sizeof(ACCESS_ALLOWED_ACE) + AclLength = sizeof(ACL) + 3 * sizeof(ACCESS_ALLOWED_ACE) +
RtlLengthSid(SystemSid) + RtlLengthSid(SystemSid) +
RtlLengthSid(RestrictedSid) + RtlLengthSid(WorldSid) +
RtlLengthSid(WorldSid); RtlLengthSid(RestrictedSid);
*Dacl = RtlAllocateHeap(BaseSrvHeap, 0, AclLength); *Dacl = RtlAllocateHeap(BaseSrvHeap, 0, AclLength);
ASSERT(*Dacl != NULL); ASSERT(*Dacl != NULL);
@ -239,9 +239,9 @@ CreateBaseAcls(OUT PACL* Dacl,
ASSERT(NT_SUCCESS(Status)); ASSERT(NT_SUCCESS(Status));
/* The SIDs are captured, can free them now */ /* The SIDs are captured, can free them now */
RtlFreeHeap(BaseSrvHeap, 0, SystemSid); RtlFreeSid(RestrictedSid);
RtlFreeHeap(BaseSrvHeap, 0, WorldSid); RtlFreeSid(WorldSid);
RtlFreeHeap(BaseSrvHeap, 0, RestrictedSid); RtlFreeSid(SystemSid);
return Status; return Status;
} }

View file

@ -350,10 +350,10 @@ GetDosDevicesProtection(OUT PSECURITY_DESCRIPTOR DosDevicesSd)
/* FIXME: semi-failure cases! Quickie: */ /* FIXME: semi-failure cases! Quickie: */
Quickie: Quickie:
/* Free the SIDs */ /* Free the SIDs */
RtlFreeSid(SystemSid);
RtlFreeSid(WorldSid);
RtlFreeSid(AdminSid);
RtlFreeSid(CreatorSid); RtlFreeSid(CreatorSid);
RtlFreeSid(AdminSid);
RtlFreeSid(WorldSid);
RtlFreeSid(SystemSid);
/* Return */ /* Return */
return Status; return Status;
@ -820,32 +820,24 @@ CsrCreateLocalSystemSD(OUT PSECURITY_DESCRIPTOR *LocalSystemSd)
/* Now create the SD itself */ /* Now create the SD itself */
Status = RtlCreateSecurityDescriptor(SystemSd, SECURITY_DESCRIPTOR_REVISION); Status = RtlCreateSecurityDescriptor(SystemSd, SECURITY_DESCRIPTOR_REVISION);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status)) goto Quit;
{
/* Fail */
RtlFreeHeap(CsrHeap, 0, SystemSd);
return Status;
}
/* Create the DACL for it */ /* Create the DACL for it */
RtlCreateAcl(Dacl, Length, ACL_REVISION2); RtlCreateAcl(Dacl, Length, ACL_REVISION2);
/* Create the ACE */ /* Create the ACE */
Status = RtlAddAccessAllowedAce(Dacl, ACL_REVISION, PORT_ALL_ACCESS, SystemSid); Status = RtlAddAccessAllowedAce(Dacl, ACL_REVISION, PORT_ALL_ACCESS, SystemSid);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status)) goto Quit;
{
/* Fail */
RtlFreeHeap(CsrHeap, 0, SystemSd);
return Status;
}
/* Clear the DACL in the SD */ /* Clear the DACL in the SD */
Status = RtlSetDaclSecurityDescriptor(SystemSd, TRUE, Dacl, FALSE); Status = RtlSetDaclSecurityDescriptor(SystemSd, TRUE, Dacl, FALSE);
if (!NT_SUCCESS(Status)) goto Quit;
Quit:
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
/* Fail */
RtlFreeHeap(CsrHeap, 0, SystemSd); RtlFreeHeap(CsrHeap, 0, SystemSd);
return Status; SystemSd = NULL;
} }
/* Free the SID and return*/ /* Free the SID and return*/