Author: tfaber Date: Sun Oct 12 11:23:05 2014 New Revision: 64689
URL: http://svn.reactos.org/svn/reactos?rev=64689&view=rev Log: [EVENTLOG] - In ElfGetLogHandleEntryByHandle, actually verify the validity of the handle by traversing the log handle list. Fixes crash in advapi32_winetest:eventlog (double close). - Minor style improvements to ElfDeleteEventLogHandle CORE-8621 #resolve
Modified: trunk/reactos/base/services/eventlog/rpc.c
Modified: trunk/reactos/base/services/eventlog/rpc.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/eventlog/rpc.... ============================================================================== --- trunk/reactos/base/services/eventlog/rpc.c [iso-8859-1] (original) +++ trunk/reactos/base/services/eventlog/rpc.c [iso-8859-1] Sun Oct 12 11:23:05 2014 @@ -196,31 +196,40 @@
PLOGHANDLE ElfGetLogHandleEntryByHandle(IELF_HANDLE EventLogHandle) { + PLIST_ENTRY CurrentEntry; PLOGHANDLE lpLogHandle;
- if (IsListEmpty(&LogHandleListHead)) - { - return NULL; - } - - lpLogHandle = CONTAINING_RECORD((PLOGHANDLE)EventLogHandle, LOGHANDLE, LogHandleListEntry); - - return lpLogHandle; + CurrentEntry = LogHandleListHead.Flink; + while (CurrentEntry != &LogHandleListHead) + { + lpLogHandle = CONTAINING_RECORD(CurrentEntry, + LOGHANDLE, + LogHandleListEntry); + CurrentEntry = CurrentEntry->Flink; + + if (lpLogHandle == EventLogHandle) + return lpLogHandle; + } + + return NULL; }
static NTSTATUS -ElfDeleteEventLogHandle(IELF_HANDLE EventLogHandle) -{ - PLOGHANDLE lpLogHandle = (PLOGHANDLE)EventLogHandle; - - if (!ElfGetLogHandleEntryByHandle(lpLogHandle)) +ElfDeleteEventLogHandle(IELF_HANDLE LogHandle) +{ + PLOGHANDLE lpLogHandle; + + lpLogHandle = ElfGetLogHandleEntryByHandle(LogHandle); + if (!lpLogHandle) + { return STATUS_INVALID_HANDLE; + }
RemoveEntryList(&lpLogHandle->LogHandleListEntry); LogfClose(lpLogHandle->LogFile, FALSE);
- HeapFree(GetProcessHeap(),0,lpLogHandle); + HeapFree(GetProcessHeap(), 0, lpLogHandle);
return STATUS_SUCCESS; }