From 497aac7ab23cea79e72c5980ba978893a1686268 Mon Sep 17 00:00:00 2001 From: Christian Walther Date: Sun, 20 Nov 2011 19:27:08 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20buffer=20size=20check=20=E2=80=93=20previ?= =?UTF-8?q?ous=20version=20could=20still=20overrun=20by=201=20or=202=20byt?= =?UTF-8?q?es.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp index 5df6ad41..99ea3b44 100644 --- a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp +++ b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp @@ -830,10 +830,12 @@ bool plStatusLog::IPrintLineToFile( const char *line, UInt32 count ) strncat(buf, work, arrsize(work)); } - if (count < arrsize(buf) - strlen(buf)) { + size_t remaining = arrsize(buf) - strlen(buf) - 1; + if (!fEncryptMe) remaining -= 1; + if (count <= remaining) { strncat(buf, line, count); } else { - strncat(buf, line, arrsize(buf) - strlen(buf)); + strncat(buf, line, remaining); } if(!fEncryptMe )