diff --git a/reactos/drivers/network/tcpip/tcpip/main.c b/reactos/drivers/network/tcpip/tcpip/main.c index 57754d67574..39f8c080297 100644 --- a/reactos/drivers/network/tcpip/tcpip/main.c +++ b/reactos/drivers/network/tcpip/tcpip/main.c @@ -50,7 +50,6 @@ VOID TiWriteErrorLog( * DumpData = Pointer to dump data for the log entry */ { -#if 0 PIO_ERROR_LOG_PACKET LogEntry; UCHAR EntrySize; ULONG StringSize; @@ -65,35 +64,37 @@ VOID TiWriteErrorLog( EntrySize += (UCHAR)StringSize; } - LogEntry = (PIO_ERROR_LOG_PACKET)IoAllocateErrorLogEntry( - DriverContext, EntrySize); + /* Fail if the required error log entry is too large */ + if (EntrySize > ERROR_LOG_MAXIMUM_SIZE) + return; - if (LogEntry) { - LogEntry->MajorFunctionCode = -1; - LogEntry->RetryCount = -1; - LogEntry->DumpDataSize = (USHORT)(DumpDataCount * sizeof(ULONG)); - LogEntry->NumberOfStrings = (String == NULL) ? 1 : 2; - LogEntry->StringOffset = sizeof(IO_ERROR_LOG_PACKET) + (DumpDataCount-1) * sizeof(ULONG); - LogEntry->EventCategory = 0; - LogEntry->ErrorCode = ErrorCode; - LogEntry->UniqueErrorValue = UniqueErrorValue; - LogEntry->FinalStatus = FinalStatus; - LogEntry->SequenceNumber = -1; - LogEntry->IoControlCode = 0; + LogEntry = (PIO_ERROR_LOG_PACKET)IoAllocateErrorLogEntry(DriverContext, EntrySize); + if (!LogEntry) + return; - if (DumpDataCount) - RtlCopyMemory(LogEntry->DumpData, DumpData, DumpDataCount * sizeof(ULONG)); + LogEntry->MajorFunctionCode = -1; + LogEntry->RetryCount = -1; + LogEntry->DumpDataSize = (USHORT)(DumpDataCount * sizeof(ULONG)); + LogEntry->NumberOfStrings = (String == NULL) ? 1 : 2; + LogEntry->StringOffset = sizeof(IO_ERROR_LOG_PACKET) + (DumpDataCount * sizeof(ULONG)); + LogEntry->EventCategory = 0; + LogEntry->ErrorCode = ErrorCode; + LogEntry->UniqueErrorValue = UniqueErrorValue; + LogEntry->FinalStatus = FinalStatus; + LogEntry->SequenceNumber = -1; + LogEntry->IoControlCode = 0; - pString = ((PUCHAR)LogEntry) + LogEntry->StringOffset; - RtlCopyMemory(pString, DriverName, sizeof(DriverName)); - pString += sizeof(DriverName); + if (DumpDataCount) + RtlCopyMemory(LogEntry->DumpData, DumpData, DumpDataCount * sizeof(ULONG)); - if (String) - RtlCopyMemory(pString, String, StringSize); + pString = ((PUCHAR)LogEntry) + LogEntry->StringOffset; + RtlCopyMemory(pString, DriverName, sizeof(DriverName)); + pString += sizeof(DriverName); - IoWriteErrorLogEntry(LogEntry); - } -#endif + if (String) + RtlCopyMemory(pString, String, StringSize); + + IoWriteErrorLogEntry(LogEntry); } /*