2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 14:37:41 +00:00

Fix buffer size check – previous version could still overrun by 1 or 2 bytes.

This commit is contained in:
Christian Walther
2011-11-20 19:27:08 +01:00
parent be39ca5210
commit 497aac7ab2

View File

@ -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 )