summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Dombrowski <stefan@uni-bonn.de>2011-04-16 11:04:06 +0200
committerStefan Dombrowski <stefan@uni-bonn.de>2011-04-16 11:04:06 +0200
commitbb795d87f9d0eebb6cc04b5c6806252fbb957f5d (patch)
tree26b72b1382fde6a3bc77f8828e162f5799cf3f2b
parent3c83cbf8055d4f13d21723f95c7c325fae8eae7a (diff)
downloadmana-bb795d87f9d0eebb6cc04b5c6806252fbb957f5d.tar.gz
mana-bb795d87f9d0eebb6cc04b5c6806252fbb957f5d.tar.bz2
mana-bb795d87f9d0eebb6cc04b5c6806252fbb957f5d.tar.xz
mana-bb795d87f9d0eebb6cc04b5c6806252fbb957f5d.zip
Fixing potential buffer overflow
Reviewed-by: Jaxad0127
-rw-r--r--src/log.cpp5
1 files 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