summaryrefslogtreecommitdiff
path: root/src/modules/m_operlevels.cpp
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2012-09-23 02:51:16 +0200
committerattilamolnar <attilamolnar@hush.com>2012-09-23 03:16:58 +0200
commit83c7cc45daf6fb1f8c36f15297a4657e45a34e88 (patch)
treec29ad7d8623eb7789c39c519de19ee414db2a95e /src/modules/m_operlevels.cpp
parentcff57f7ba780a5c4fc331ccbab489abdc572379c (diff)
Fix undefined behavior caused by referencing the returned buffer by std::string::c_str() when the object is temporary
Thanks to @ChrisTX for pointing this out Fixes #257 reported by @helloall
Diffstat (limited to 'src/modules/m_operlevels.cpp')
-rw-r--r--src/modules/m_operlevels.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/modules/m_operlevels.cpp b/src/modules/m_operlevels.cpp
index 7e28f6c21..4fc4c6aef 100644
--- a/src/modules/m_operlevels.cpp
+++ b/src/modules/m_operlevels.cpp
@@ -42,8 +42,11 @@ class ModuleOperLevels : public Module
// oper killing an oper?
if (IS_OPER(dest) && IS_OPER(source))
{
- long dest_level = atol(dest->oper->getConfig("level").c_str());
- long source_level = atol(source->oper->getConfig("level").c_str());
+ std::string level = dest->oper->getConfig("level");
+ long dest_level = atol(level.c_str());
+ level = source->oper->getConfig("level");
+ long source_level = atol(level.c_str());
+
if (dest_level > source_level)
{
if (IS_LOCAL(source)) ServerInstance->SNO->WriteGlobalSno('a', "Oper %s (level %ld) attempted to /kill a higher oper: %s (level %ld): Reason: %s",source->nick.c_str(),source_level,dest->nick.c_str(),dest_level,reason.c_str());