summaryrefslogtreecommitdiff
path: root/src/log.cpp
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-10-25 00:01:57 +0200
committerest31 <MTest31@outlook.com>2015-10-25 00:13:01 +0200
commit1f76808e4fa5a198f1dbddba6fa18ea1ecb20cb6 (patch)
treea9bd6ef2de9630482626572550dfba3db5b2aede /src/log.cpp
parent7d5c7365314c9517369a7a7d6e4fc5d8712b93c7 (diff)
downloadminetest-1f76808e4fa5a198f1dbddba6fa18ea1ecb20cb6.tar.gz
minetest-1f76808e4fa5a198f1dbddba6fa18ea1ecb20cb6.tar.bz2
minetest-1f76808e4fa5a198f1dbddba6fa18ea1ecb20cb6.zip
Fix out of bounds vector write in Logger::addOutput(ILogOutput *out)
Previously, the invocation of Logger::addOutput(ILogOutput *out) led to an out of bounds write of the m_outputs vector, resulting in the m_silenced_levels array being modified. Fortunately, the only caller of that method was android system logging, and only since a few commits ago.
Diffstat (limited to 'src/log.cpp')
-rw-r--r--src/log.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/log.cpp b/src/log.cpp
index 7cae8b670..3ffd66673 100644
--- a/src/log.cpp
+++ b/src/log.cpp
@@ -172,7 +172,7 @@ LogLevel Logger::stringToLevel(const std::string &name)
void Logger::addOutput(ILogOutput *out)
{
- addOutputMaxLevel(out, LL_MAX);
+ addOutputMaxLevel(out, (LogLevel)(LL_MAX - 1));
}
void Logger::addOutput(ILogOutput *out, LogLevel lev)
@@ -182,6 +182,7 @@ void Logger::addOutput(ILogOutput *out, LogLevel lev)
void Logger::addOutputMaxLevel(ILogOutput *out, LogLevel lev)
{
+ assert(lev < LL_MAX);
for (size_t i = 0; i <= lev; i++)
m_outputs[i].push_back(out);
}