From 030163b1d92aea6cd0c2d268d4997bd7984a376b Mon Sep 17 00:00:00 2001 From: def Date: Sat, 6 Nov 2021 12:57:31 +0100 Subject: [PATCH] Don't access out of bounds in linereader (fixes #4308) --- src/engine/shared/linereader.cpp | 2 +- src/engine/shared/linereader.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/shared/linereader.cpp b/src/engine/shared/linereader.cpp index 18868e151..05c97f9af 100644 --- a/src/engine/shared/linereader.cpp +++ b/src/engine/shared/linereader.cpp @@ -4,7 +4,7 @@ void CLineReader::Init(IOHANDLE File) { - m_BufferMaxSize = sizeof(m_aBuffer); + m_BufferMaxSize = sizeof(m_aBuffer) - 1; m_BufferSize = 0; m_BufferPos = 0; m_File = File; diff --git a/src/engine/shared/linereader.h b/src/engine/shared/linereader.h index b66bcf82b..b97cd40ef 100644 --- a/src/engine/shared/linereader.h +++ b/src/engine/shared/linereader.h @@ -7,7 +7,7 @@ // buffered stream for reading lines, should perhaps be something smaller class CLineReader { - char m_aBuffer[4 * 8192]; + char m_aBuffer[4 * 8192 + 1]; // 1 additional byte for null termination unsigned m_BufferPos; unsigned m_BufferSize; unsigned m_BufferMaxSize;