diff options
author | attilamolnar <attilamolnar@hush.com> | 2012-09-23 02:51:16 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2012-09-23 03:16:58 +0200 |
commit | 83c7cc45daf6fb1f8c36f15297a4657e45a34e88 (patch) | |
tree | c29ad7d8623eb7789c39c519de19ee414db2a95e /src/modules | |
parent | cff57f7ba780a5c4fc331ccbab489abdc572379c (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')
-rw-r--r-- | src/modules/m_alias.cpp | 3 | ||||
-rw-r--r-- | src/modules/m_httpd.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_operlevels.cpp | 7 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 3 |
4 files changed, 10 insertions, 5 deletions
diff --git a/src/modules/m_alias.cpp b/src/modules/m_alias.cpp index ec426fe9b..6cb336c83 100644 --- a/src/modules/m_alias.cpp +++ b/src/modules/m_alias.cpp @@ -87,7 +87,8 @@ class ModuleAlias : public Module { ConfigTag* tag = i->second; Alias a; - a.AliasedCommand = tag->getString("text").c_str(); + std::string aliastext = tag->getString("text"); + a.AliasedCommand = aliastext.c_str(); tag->readString("replace", a.ReplaceFormat, true); a.RequiredNick = tag->getString("requires"); a.ULineOnly = tag->getBool("uline"); diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index 0584e97c5..bf86c9091 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -282,7 +282,7 @@ class HttpServerSocket : public BufferedSocket return; } - if (headers.IsSet("Content-Length") && (postsize = atoi(headers.GetHeader("Content-Length").c_str())) != 0) + if (headers.IsSet("Content-Length") && (postsize = ConvToInt(headers.GetHeader("Content-Length"))) != 0) { InternalState = HTTP_SERVE_RECV_POSTDATA; 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()); diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 75d4eaca3..11fdeb6cc 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -374,7 +374,8 @@ void SpanningTreeUtilities::ReadConfiguration() { ConfigTag* tag = i->second; reference<Link> L = new Link(tag); - L->Name = tag->getString("name").c_str(); + std::string linkname = tag->getString("name"); + L->Name = linkname.c_str(); L->AllowMask = tag->getString("allowmask"); L->IPAddr = tag->getString("ipaddr"); L->Port = tag->getInt("port"); |