Author: hbelusca
Date: Sun Apr 7 18:28:38 2013
New Revision: 58716
URL:
http://svn.reactos.org/svn/reactos?rev=58716&view=rev
Log:
[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 ).
Modified:
branches/ros-csrss/dll/ntdll/csr/connect.c
branches/ros-csrss/subsystems/win/basesrv/dosdev.c
branches/ros-csrss/subsystems/win/basesrv/init.c
branches/ros-csrss/subsystems/win32/csrsrv/init.c
Modified: branches/ros-csrss/dll/ntdll/csr/connect.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/ntdll/csr/connect…
==============================================================================
--- branches/ros-csrss/dll/ntdll/csr/connect.c [iso-8859-1] (original)
+++ branches/ros-csrss/dll/ntdll/csr/connect.c [iso-8859-1] Sun Apr 7 18:28:38 2013
@@ -221,7 +221,7 @@
NULL,
&CsrSectionViewSize,
PAGE_READWRITE,
- SEC_COMMIT,
+ SEC_RESERVE,
NULL);
if (!NT_SUCCESS(Status))
{
@@ -250,16 +250,16 @@
/* Create a SID for us */
Status = RtlAllocateAndInitializeSid(&NtSidAuthority,
- 1,
- SECURITY_LOCAL_SYSTEM_RID,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- &SystemSid);
+ 1,
+ SECURITY_LOCAL_SYSTEM_RID,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ &SystemSid);
if (!NT_SUCCESS(Status))
{
/* Failure */
@@ -278,6 +278,7 @@
NULL,
&ConnectionInfo,
&ConnectionInfoLength);
+ RtlFreeSid(SystemSid);
NtClose(CsrSectionHandle);
if (!NT_SUCCESS(Status))
{
Modified: branches/ros-csrss/subsystems/win/basesrv/dosdev.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/subsystems/win/basesr…
==============================================================================
--- branches/ros-csrss/subsystems/win/basesrv/dosdev.c [iso-8859-1] (original)
+++ branches/ros-csrss/subsystems/win/basesrv/dosdev.c [iso-8859-1] Sun Apr 7 18:28:38
2013
@@ -420,8 +420,8 @@
&AdminSid);
SidLength = RtlLengthSid(SystemSid) +
- RtlLengthSid(AdminSid) +
- RtlLengthSid(WorldSid);
+ RtlLengthSid(AdminSid) +
+ RtlLengthSid(WorldSid);
Length = sizeof(ACL) + SidLength + 3 * sizeof(ACCESS_ALLOWED_ACE);
SecurityDescriptor = RtlAllocateHeap(BaseSrvHeap,
Modified: branches/ros-csrss/subsystems/win/basesrv/init.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/subsystems/win/basesr…
==============================================================================
--- branches/ros-csrss/subsystems/win/basesrv/init.c [iso-8859-1] (original)
+++ branches/ros-csrss/subsystems/win/basesrv/init.c [iso-8859-1] Sun Apr 7 18:28:38
2013
@@ -202,9 +202,9 @@
/* Allocate one ACL with 3 ACEs each for one SID */
AclLength = sizeof(ACL) + 3 * sizeof(ACCESS_ALLOWED_ACE) +
- RtlLengthSid(SystemSid) +
- RtlLengthSid(RestrictedSid) +
- RtlLengthSid(WorldSid);
+ RtlLengthSid(SystemSid) +
+ RtlLengthSid(WorldSid) +
+ RtlLengthSid(RestrictedSid);
*Dacl = RtlAllocateHeap(BaseSrvHeap, 0, AclLength);
ASSERT(*Dacl != NULL);
@@ -239,9 +239,9 @@
ASSERT(NT_SUCCESS(Status));
/* The SIDs are captured, can free them now */
- RtlFreeHeap(BaseSrvHeap, 0, SystemSid);
- RtlFreeHeap(BaseSrvHeap, 0, WorldSid);
- RtlFreeHeap(BaseSrvHeap, 0, RestrictedSid);
+ RtlFreeSid(RestrictedSid);
+ RtlFreeSid(WorldSid);
+ RtlFreeSid(SystemSid);
return Status;
}
Modified: branches/ros-csrss/subsystems/win32/csrsrv/init.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/subsystems/win32/csrs…
==============================================================================
--- branches/ros-csrss/subsystems/win32/csrsrv/init.c [iso-8859-1] (original)
+++ branches/ros-csrss/subsystems/win32/csrsrv/init.c [iso-8859-1] Sun Apr 7 18:28:38
2013
@@ -350,10 +350,10 @@
/* FIXME: semi-failure cases! Quickie: */
Quickie:
/* Free the SIDs */
+ RtlFreeSid(CreatorSid);
+ RtlFreeSid(AdminSid);
+ RtlFreeSid(WorldSid);
RtlFreeSid(SystemSid);
- RtlFreeSid(WorldSid);
- RtlFreeSid(AdminSid);
- RtlFreeSid(CreatorSid);
/* Return */
return Status;
@@ -820,32 +820,24 @@
/* Now create the SD itself */
Status = RtlCreateSecurityDescriptor(SystemSd, SECURITY_DESCRIPTOR_REVISION);
- if (!NT_SUCCESS(Status))
- {
- /* Fail */
- RtlFreeHeap(CsrHeap, 0, SystemSd);
- return Status;
- }
+ if (!NT_SUCCESS(Status)) goto Quit;
/* Create the DACL for it */
RtlCreateAcl(Dacl, Length, ACL_REVISION2);
/* Create the ACE */
Status = RtlAddAccessAllowedAce(Dacl, ACL_REVISION, PORT_ALL_ACCESS, SystemSid);
- if (!NT_SUCCESS(Status))
- {
- /* Fail */
- RtlFreeHeap(CsrHeap, 0, SystemSd);
- return Status;
- }
+ if (!NT_SUCCESS(Status)) goto Quit;
/* Clear the DACL in the SD */
Status = RtlSetDaclSecurityDescriptor(SystemSd, TRUE, Dacl, FALSE);
- if (!NT_SUCCESS(Status))
- {
- /* Fail */
+ if (!NT_SUCCESS(Status)) goto Quit;
+
+Quit:
+ if (!NT_SUCCESS(Status))
+ {
RtlFreeHeap(CsrHeap, 0, SystemSd);
- return Status;
+ SystemSd = NULL;
}
/* Free the SID and return*/