https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b5af1eb44a29025055c092066bc711bc4348bd3c

commit b5af1eb44a29025055c092066bc711bc4348bd3c
Author:     Serge Gautherie <[email protected]>
AuthorDate: Mon Jun 1 20:20:31 2020 +0200
Commit:     GitHub <[email protected]>
CommitDate: Mon Jun 1 20:20:31 2020 +0200

    [CSRSRV] CsrUnhandledExceptionFilter: Check RtlAdjustPrivilege() result 
(#2864)
    
    And remove unused NtRaiseHardError() Status assignment.
    
    Detected by Cppcheck: redundantAssignment.
    Related to commit d221bdfb (r55647).
---
 subsystems/win32/csrsrv/server.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/subsystems/win32/csrsrv/server.c b/subsystems/win32/csrsrv/server.c
index 4fa35367927..3fce78b7fc5 100644
--- a/subsystems/win32/csrsrv/server.c
+++ b/subsystems/win32/csrsrv/server.c
@@ -659,6 +659,11 @@ CsrUnhandledExceptionFilter(IN PEXCEPTION_POINTERS 
ExceptionInfo)
                                             FALSE,
                                             &OldValue);
             }
+            if (!NT_SUCCESS(Status))
+            {
+                DPRINT1("CsrUnhandledExceptionFilter(): 
RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE) failed, Status = 0x%08lx\n", Status);
+                goto NoPrivilege;
+            }
 
             /* Initialize our Name String */
             RtlInitUnicodeString(&ErrorSource, L"Windows SubSystem");
@@ -670,14 +675,15 @@ CsrUnhandledExceptionFilter(IN PEXCEPTION_POINTERS 
ExceptionInfo)
             ErrorParameters[3] = (ULONG_PTR)ExceptionInfo->ContextRecord;
 
             /* Bugcheck */
-            Status = NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED,
-                                      4,
-                                      1,
-                                      ErrorParameters,
-                                      OptionShutdownSystem,
-                                      &Response);
+            NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED,
+                             4,
+                             1,
+                             ErrorParameters,
+                             OptionShutdownSystem,
+                             &Response);
         }
 
+NoPrivilege:
         /* Just terminate us */
         NtTerminateProcess(NtCurrentProcess(),
                            ExceptionInfo->ExceptionRecord->ExceptionCode);

Reply via email to