Browse Source

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

Christian Walther 13 years ago
parent
commit
497aac7ab2
  1. 6
      Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp

6
Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp

@ -830,10 +830,12 @@ bool plStatusLog::IPrintLineToFile( const char *line, UInt32 count )
strncat(buf, work, arrsize(work)); 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); strncat(buf, line, count);
} else { } else {
strncat(buf, line, arrsize(buf) - strlen(buf)); strncat(buf, line, remaining);
} }
if(!fEncryptMe ) if(!fEncryptMe )

Loading…
Cancel
Save