From bb795d87f9d0eebb6cc04b5c6806252fbb957f5d Mon Sep 17 00:00:00 2001 From: Stefan Dombrowski Date: Sat, 16 Apr 2011 11:04:06 +0200 Subject: Fixing potential buffer overflow Reviewed-by: Jaxad0127 --- src/log.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/log.cpp b/src/log.cpp index 5880e108..4ce1cd83 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -61,12 +61,13 @@ void Logger::setLogFile(const std::string &logFilename) void Logger::log(const char *log_text, ...) { - char* buf = new char[1024]; + const size_t bufSize = 1024; + char* buf = new char[bufSize]; va_list ap; // Use a temporary buffer to fill in the variables va_start(ap, log_text); - vsprintf(buf, log_text, ap); + vsnprintf(buf, bufSize, log_text, ap); va_end(ap); // Get the current system time -- cgit v1.2.3-60-g2f50