From 323bd187719ecc9605074c5f3a14257a2a5a6cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 7 Nov 2016 13:57:11 +0000 Subject: [PATCH] [NTOS:IO]: An improvement for the total log size check (addendum to r73167). svn path=/trunk/; revision=73168 --- reactos/ntoskrnl/io/iomgr/error.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/reactos/ntoskrnl/io/iomgr/error.c b/reactos/ntoskrnl/io/iomgr/error.c index e21cb9025d0..dea65698c9a 100644 --- a/reactos/ntoskrnl/io/iomgr/error.c +++ b/reactos/ntoskrnl/io/iomgr/error.c @@ -554,10 +554,6 @@ IoAllocateErrorLogEntry(IN PVOID IoObject, return NULL; } - /* Check if we're past our buffer */ - // FIXME/TODO: Perform the checks by taking into account EntrySize. - if (IopTotalLogSize > IOP_MAXIMUM_LOG_SIZE) return NULL; - /* Check whether the size is too small or too large */ if ((EntrySize < sizeof(IO_ERROR_LOG_PACKET)) || (EntrySize > ERROR_LOG_MAXIMUM_SIZE)) @@ -566,11 +562,15 @@ IoAllocateErrorLogEntry(IN PVOID IoObject, return NULL; } - /* Round up the size */ + /* Round up the size and calculate the total size */ EntrySize = ROUND_UP(EntrySize, sizeof(PVOID)); - - /* Calculate the total size and allocate it */ LogEntrySize = sizeof(ERROR_LOG_ENTRY) + EntrySize; + + /* Check if we're past our buffer */ + // TODO: Improve (what happens in case of concurrent calls?) + if (IopTotalLogSize + LogEntrySize > IOP_MAXIMUM_LOG_SIZE) return NULL; + + /* Allocate the entry */ LogEntry = ExAllocatePoolWithTag(NonPagedPool, LogEntrySize, TAG_ERROR_LOG);