summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2012-09-30 01:10:57 +0200
committerattilamolnar <attilamolnar@hush.com>2012-09-30 03:04:07 +0200
commit02859be56d43bcece02aab350e02bc95ed1bf446 (patch)
treebbb68a91e26f4502c22047ad2b26ed8918c5fbb1 /src
parent83e90c4baa1215caf05295aec86a0a4d7bfff3f9 (diff)
Fix more undefined behavior caused by referencing the returned buffer by std::string::c_str() when the object is temporary
See 83c7cc45daf6fb1f8c36f15297a4657e45a34e88
Diffstat (limited to 'src')
-rw-r--r--src/channels.cpp3
-rw-r--r--src/commands/cmd_eline.cpp3
-rw-r--r--src/commands/cmd_gline.cpp3
-rw-r--r--src/commands/cmd_kline.cpp3
-rw-r--r--src/commands/cmd_qline.cpp3
-rw-r--r--src/commands/cmd_version.cpp3
-rw-r--r--src/commands/cmd_zline.cpp3
-rw-r--r--src/dns.cpp4
-rw-r--r--src/modmanager_dynamic.cpp5
-rw-r--r--src/modules/extra/m_ldapauth.cpp3
-rw-r--r--src/modules/m_cban.cpp3
-rw-r--r--src/modules/m_censor.cpp7
-rw-r--r--src/modules/m_connectban.cpp8
-rw-r--r--src/modules/m_dnsbl.cpp33
-rw-r--r--src/modules/m_kicknorejoin.cpp5
-rw-r--r--src/modules/m_operlog.cpp7
-rw-r--r--src/modules/m_opermotd.cpp5
-rw-r--r--src/modules/m_override.cpp2
-rw-r--r--src/modules/m_password_hash.cpp3
-rw-r--r--src/modules/m_redirect.cpp2
-rw-r--r--src/modules/m_rline.cpp6
-rw-r--r--src/modules/m_shun.cpp3
-rw-r--r--src/modules/m_silence.cpp14
-rw-r--r--src/modules/m_spanningtree/addline.cpp8
-rw-r--r--src/modules/m_spanningtree/delline.cpp2
-rw-r--r--src/modules/m_spanningtree/main.cpp15
-rw-r--r--src/modules/m_spanningtree/netburst.cpp4
-rw-r--r--src/modules/m_spanningtree/override_map.cpp7
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp3
-rw-r--r--src/modules/m_spanningtree/treesocket2.cpp5
-rw-r--r--src/modules/m_svshold.cpp3
-rw-r--r--src/server.cpp5
-rw-r--r--src/socket.cpp2
-rw-r--r--src/users.cpp6
-rw-r--r--src/whois.cpp3
35 files changed, 128 insertions, 66 deletions
diff --git a/src/channels.cpp b/src/channels.cpp
index c265171b5..855fd0e15 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -1013,7 +1013,8 @@ Invitation* Invitation::Find(Channel* c, LocalUser* u, bool check_expired)
if ((check_expired) && (inv->expiry != 0) && (inv->expiry <= ServerInstance->Time()))
{
/* Expired invite, remove it. */
- ServerInstance->Logs->Log("INVITATION", DEBUG, "Invitation::Find ecountered expired entry: %p expired %s", (void*) inv, ServerInstance->TimeString(inv->expiry).c_str());
+ std::string expiration = ServerInstance->TimeString(inv->expiry);
+ ServerInstance->Logs->Log("INVITATION", DEBUG, "Invitation::Find ecountered expired entry: %p expired %s", (void*) inv, expiration.c_str());
i = locallist.erase(i);
inv->cull();
delete inv;
diff --git a/src/commands/cmd_eline.cpp b/src/commands/cmd_eline.cpp
index 15487bd8e..43eb678ee 100644
--- a/src/commands/cmd_eline.cpp
+++ b/src/commands/cmd_eline.cpp
@@ -81,8 +81,9 @@ CmdResult CommandEline::Handle (const std::vector<std::string>& parameters, User
else
{
time_t c_requires_crap = duration + ServerInstance->Time();
+ std::string timestr = ServerInstance->TimeString(c_requires_crap);
ServerInstance->SNO->WriteToSnoMask('x',"%s added timed E-line for %s, expires on %s: %s",user->nick.c_str(),target.c_str(),
- ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
+ timestr.c_str(), parameters[2].c_str());
}
}
else
diff --git a/src/commands/cmd_gline.cpp b/src/commands/cmd_gline.cpp
index f4f962569..430256be8 100644
--- a/src/commands/cmd_gline.cpp
+++ b/src/commands/cmd_gline.cpp
@@ -87,8 +87,9 @@ CmdResult CommandGline::Handle (const std::vector<std::string>& parameters, User
else
{
time_t c_requires_crap = duration + ServerInstance->Time();
+ std::string timestr = ServerInstance->TimeString(c_requires_crap);
ServerInstance->SNO->WriteToSnoMask('x',"%s added timed G-line for %s, expires on %s: %s",user->nick.c_str(),target.c_str(),
- ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
+ timestr.c_str(), parameters[2].c_str());
}
ServerInstance->XLines->ApplyLines();
diff --git a/src/commands/cmd_kline.cpp b/src/commands/cmd_kline.cpp
index 6c2789557..b1f5f62db 100644
--- a/src/commands/cmd_kline.cpp
+++ b/src/commands/cmd_kline.cpp
@@ -87,8 +87,9 @@ CmdResult CommandKline::Handle (const std::vector<std::string>& parameters, User
else
{
time_t c_requires_crap = duration + ServerInstance->Time();
+ std::string timestr = ServerInstance->TimeString(c_requires_crap);
ServerInstance->SNO->WriteToSnoMask('x',"%s added timed K-line for %s, expires on %s: %s",user->nick.c_str(),target.c_str(),
- ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
+ timestr.c_str(), parameters[2].c_str());
}
ServerInstance->XLines->ApplyLines();
diff --git a/src/commands/cmd_qline.cpp b/src/commands/cmd_qline.cpp
index 64ba1a78b..3118798e6 100644
--- a/src/commands/cmd_qline.cpp
+++ b/src/commands/cmd_qline.cpp
@@ -63,8 +63,9 @@ CmdResult CommandQline::Handle (const std::vector<std::string>& parameters, User
else
{
time_t c_requires_crap = duration + ServerInstance->Time();
+ std::string timestr = ServerInstance->TimeString(c_requires_crap);
ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Q-line for %s, expires on %s: %s",user->nick.c_str(),parameters[0].c_str(),
- ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
+ timestr.c_str(), parameters[2].c_str());
}
ServerInstance->XLines->ApplyLines();
}
diff --git a/src/commands/cmd_version.cpp b/src/commands/cmd_version.cpp
index 6fae329bd..7620197fd 100644
--- a/src/commands/cmd_version.cpp
+++ b/src/commands/cmd_version.cpp
@@ -42,7 +42,8 @@ class CommandVersion : public Command
CmdResult CommandVersion::Handle (const std::vector<std::string>&, User *user)
{
- user->WriteNumeric(RPL_VERSION, "%s :%s",user->nick.c_str(),ServerInstance->GetVersionString(IS_OPER(user)).c_str());
+ std::string version = ServerInstance->GetVersionString(IS_OPER(user));
+ user->WriteNumeric(RPL_VERSION, "%s :%s", user->nick.c_str(), version.c_str());
ServerInstance->Config->Send005(user);
return CMD_SUCCESS;
}
diff --git a/src/commands/cmd_zline.cpp b/src/commands/cmd_zline.cpp
index cee7f616d..3e940a9bd 100644
--- a/src/commands/cmd_zline.cpp
+++ b/src/commands/cmd_zline.cpp
@@ -84,8 +84,9 @@ CmdResult CommandZline::Handle (const std::vector<std::string>& parameters, User
else
{
time_t c_requires_crap = duration + ServerInstance->Time();
+ std::string timestr = ServerInstance->TimeString(c_requires_crap);
ServerInstance->SNO->WriteToSnoMask('x',"%s added timed Z-line for %s, expires on %s: %s",user->nick.c_str(),ipaddr,
- ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
+ timestr.c_str(), parameters[2].c_str());
}
ServerInstance->XLines->ApplyLines();
}
diff --git a/src/dns.cpp b/src/dns.cpp
index 17641c585..1c23710a4 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -596,8 +596,10 @@ DNSResult DNS::GetResult()
*/
if (from != myserver)
{
+ std::string server1 = from.str();
+ std::string server2 = myserver.str();
ServerInstance->Logs->Log("RESOLVER",DEBUG,"Got a result from the wrong server! Bad NAT or DNS forging attempt? '%s' != '%s'",
- from.str().c_str(), myserver.str().c_str());
+ server1.c_str(), server2.c_str());
return DNSResult(-1,"",0,"");
}
diff --git a/src/modmanager_dynamic.cpp b/src/modmanager_dynamic.cpp
index e613508df..e0d744b3a 100644
--- a/src/modmanager_dynamic.cpp
+++ b/src/modmanager_dynamic.cpp
@@ -66,10 +66,11 @@ bool ModuleManager::Load(const std::string& filename, bool defer)
newmod->ModuleSourceFile = filename;
newmod->ModuleDLLManager = newhandle;
Modules[filename] = newmod;
+ std::string version = newhandle->GetVersion();
if (defer)
{
ServerInstance->Logs->Log("MODULE", DEFAULT,"New module introduced: %s (Module version %s)",
- filename.c_str(), newhandle->GetVersion().c_str());
+ filename.c_str(), version.c_str());
}
else
{
@@ -77,7 +78,7 @@ bool ModuleManager::Load(const std::string& filename, bool defer)
Version v = newmod->GetVersion();
ServerInstance->Logs->Log("MODULE", DEFAULT,"New module introduced: %s (Module version %s)%s",
- filename.c_str(), newhandle->GetVersion().c_str(), (!(v.Flags & VF_VENDOR) ? " [3rd Party]" : " [Vendor]"));
+ filename.c_str(), version.c_str(), (!(v.Flags & VF_VENDOR) ? " [3rd Party]" : " [Vendor]"));
}
}
else
diff --git a/src/modules/extra/m_ldapauth.cpp b/src/modules/extra/m_ldapauth.cpp
index 0f1ca74d7..1b6a3a0d9 100644
--- a/src/modules/extra/m_ldapauth.cpp
+++ b/src/modules/extra/m_ldapauth.cpp
@@ -208,7 +208,8 @@ public:
size_t pos = user->password.find(":");
if (pos != std::string::npos)
{
- res = ldap_search_ext_s(conn, base.c_str(), searchscope, user->password.substr(0, pos).c_str(), NULL, 0, NULL, NULL, NULL, 0, &msg);
+ std::string cutpassword = user->password.substr(0, pos);
+ res = ldap_search_ext_s(conn, base.c_str(), searchscope, cutpassword.c_str(), NULL, 0, NULL, NULL, NULL, 0, &msg);
if (res)
{
diff --git a/src/modules/m_cban.cpp b/src/modules/m_cban.cpp
index 92f97158e..0157a4add 100644
--- a/src/modules/m_cban.cpp
+++ b/src/modules/m_cban.cpp
@@ -131,7 +131,8 @@ class CommandCBan : public Command
else
{
time_t c_requires_crap = duration + ServerInstance->Time();
- ServerInstance->SNO->WriteGlobalSno('x', "%s added timed CBan for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), reason);
+ std::string timestr = ServerInstance->TimeString(c_requires_crap);
+ ServerInstance->SNO->WriteGlobalSno('x', "%s added timed CBan for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), timestr.c_str(), reason);
}
}
else
diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp
index 5e832cc8b..bbf061f7e 100644
--- a/src/modules/m_censor.cpp
+++ b/src/modules/m_censor.cpp
@@ -128,9 +128,10 @@ class ModuleCensor : public Module
for (int index = 0; index < MyConf.Enumerate("badword"); index++)
{
- irc::string pattern = (MyConf.ReadValue("badword","text",index)).c_str();
- irc::string replace = (MyConf.ReadValue("badword","replace",index)).c_str();
- censors[pattern] = replace;
+ std::string str = MyConf.ReadValue("badword","text",index);
+ irc::string pattern(str.c_str());
+ str = MyConf.ReadValue("badword","replace",index);
+ censors[pattern] = irc::string(str.c_str());
}
}
diff --git a/src/modules/m_connectban.cpp b/src/modules/m_connectban.cpp
index 00452a8f2..aebe9a4ca 100644
--- a/src/modules/m_connectban.cpp
+++ b/src/modules/m_connectban.cpp
@@ -103,9 +103,11 @@ class ModuleConnectBan : public Module
else
delete zl;
- ServerInstance->SNO->WriteGlobalSno('x',"Module m_connectban added Z:line on *@%s to expire on %s: Connect flooding",
- mask.str().c_str(), ServerInstance->TimeString(zl->expiry).c_str());
- ServerInstance->SNO->WriteGlobalSno('a', "Connect flooding from IP range %s (%d)", mask.str().c_str(), threshold);
+ std::string maskstr = mask.str();
+ std::string timestr = ServerInstance->TimeString(zl->expiry);
+ ServerInstance->SNO->WriteGlobalSno('x',"Module m_connectban added Z:line on *@%s to expire on %s: Connect flooding",
+ maskstr.c_str(), timestr.c_str());
+ ServerInstance->SNO->WriteGlobalSno('a', "Connect flooding from IP range %s (%d)", maskstr.c_str(), threshold);
connects.erase(i);
}
}
diff --git a/src/modules/m_dnsbl.cpp b/src/modules/m_dnsbl.cpp
index 645949006..52500dec8 100644
--- a/src/modules/m_dnsbl.cpp
+++ b/src/modules/m_dnsbl.cpp
@@ -142,8 +142,9 @@ class DNSBLResolver : public Resolver
"*", them->GetIPString());
if (ServerInstance->XLines->AddLine(kl,NULL))
{
- ServerInstance->SNO->WriteGlobalSno('x',"K:line added due to DNSBL match on *@%s to expire on %s: %s",
- them->GetIPString(), ServerInstance->TimeString(kl->expiry).c_str(), reason.c_str());
+ std::string timestr = ServerInstance->TimeString(kl->expiry);
+ ServerInstance->SNO->WriteGlobalSno('x',"K:line added due to DNSBL match on *@%s to expire on %s: %s",
+ them->GetIPString(), timestr.c_str(), reason.c_str());
ServerInstance->XLines->ApplyLines();
}
else
@@ -156,8 +157,9 @@ class DNSBLResolver : public Resolver
"*", them->GetIPString());
if (ServerInstance->XLines->AddLine(gl,NULL))
{
- ServerInstance->SNO->WriteGlobalSno('x',"G:line added due to DNSBL match on *@%s to expire on %s: %s",
- them->GetIPString(), ServerInstance->TimeString(gl->expiry).c_str(), reason.c_str());
+ std::string timestr = ServerInstance->TimeString(gl->expiry);
+ ServerInstance->SNO->WriteGlobalSno('x',"G:line added due to DNSBL match on *@%s to expire on %s: %s",
+ them->GetIPString(), timestr.c_str(), reason.c_str());
ServerInstance->XLines->ApplyLines();
}
else
@@ -170,8 +172,9 @@ class DNSBLResolver : public Resolver
them->GetIPString());
if (ServerInstance->XLines->AddLine(zl,NULL))
{
- ServerInstance->SNO->WriteGlobalSno('x',"Z:line added due to DNSBL match on *@%s to expire on %s: %s",
- them->GetIPString(), ServerInstance->TimeString(zl->expiry).c_str(), reason.c_str());
+ std::string timestr = ServerInstance->TimeString(zl->expiry);
+ ServerInstance->SNO->WriteGlobalSno('x',"Z:line added due to DNSBL match on *@%s to expire on %s: %s",
+ them->GetIPString(), timestr.c_str(), reason.c_str());
ServerInstance->XLines->ApplyLines();
}
else
@@ -307,29 +310,35 @@ class ModuleDNSBL : public Module
/* yeah, logic here is a little messy */
if ((e->bitmask <= 0) && (DNSBLConfEntry::A_BITMASK == e->type))
{
- ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): invalid bitmask",tag->getTagLocation().c_str());
+ std::string location = tag->getTagLocation();
+ ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): invalid bitmask", location.c_str());
}
else if (e->name.empty())
{
- ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid name",tag->getTagLocation().c_str());
+ std::string location = tag->getTagLocation();
+ ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid name", location.c_str());
}
else if (e->domain.empty())
{
- ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid domain",tag->getTagLocation().c_str());
+ std::string location = tag->getTagLocation();
+ ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid domain", location.c_str());
}
else if (e->banaction == DNSBLConfEntry::I_UNKNOWN)
{
- ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid banaction",tag->getTagLocation().c_str());
+ std::string location = tag->getTagLocation();
+ ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid banaction", location.c_str());
}
else if (e->duration <= 0)
{
- ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid duration",tag->getTagLocation().c_str());
+ std::string location = tag->getTagLocation();
+ ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): Invalid duration", location.c_str());
}
else
{
if (e->reason.empty())
{
- ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): empty reason, using defaults",tag->getTagLocation().c_str());
+ std::string location = tag->getTagLocation();
+ ServerInstance->SNO->WriteGlobalSno('a', "DNSBL(%s): empty reason, using defaults", location.c_str());
e->reason = "Your IP has been blacklisted.";
}
diff --git a/src/modules/m_kicknorejoin.cpp b/src/modules/m_kicknorejoin.cpp
index 520e5b005..7abb9be7b 100644
--- a/src/modules/m_kicknorejoin.cpp
+++ b/src/modules/m_kicknorejoin.cpp
@@ -86,8 +86,9 @@ public:
{
if (iter->first == user)
{
+ std::string modeparam = chan->GetModeParameter(&kr);
user->WriteNumeric(ERR_DELAYREJOIN, "%s %s :You must wait %s seconds after being kicked to rejoin (+J)",
- user->nick.c_str(), chan->name.c_str(), chan->GetModeParameter(&kr).c_str());
+ user->nick.c_str(), chan->name.c_str(), modeparam.c_str());
return MOD_RES_DENY;
}
}
@@ -118,7 +119,7 @@ public:
dl = new delaylist;
kr.ext.set(memb->chan, dl);
}
- (*dl)[memb->user] = ServerInstance->Time() + atoi(memb->chan->GetModeParameter(&kr).c_str());
+ (*dl)[memb->user] = ServerInstance->Time() + ConvToInt(memb->chan->GetModeParameter(&kr));
}
}
diff --git a/src/modules/m_operlog.cpp b/src/modules/m_operlog.cpp
index cc533dbf5..d8006d9d5 100644
--- a/src/modules/m_operlog.cpp
+++ b/src/modules/m_operlog.cpp
@@ -54,7 +54,12 @@ class ModuleOperLog : public Module
{
Command* thiscommand = ServerInstance->Parser->GetHandler(command);
if ((thiscommand) && (thiscommand->flags_needed == 'o'))
- ServerInstance->Logs->Log("m_operlog",DEFAULT,"OPERLOG: [%s!%s@%s] %s %s",user->nick.c_str(), user->ident.c_str(), user->host.c_str(), command.c_str(), parameters.empty() ? "" : irc::stringjoiner(" ", parameters, 0, parameters.size() - 1).GetJoined().c_str());
+ {
+ std::string line;
+ if (!parameters.empty())
+ line = irc::stringjoiner(" ", parameters, 0, parameters.size() - 1).GetJoined();
+ ServerInstance->Logs->Log("m_operlog",DEFAULT,"OPERLOG: [%s!%s@%s] %s %s",user->nick.c_str(), user->ident.c_str(), user->host.c_str(), command.c_str(), line.c_str());
+ }
}
return MOD_RES_PASSTHRU;
diff --git a/src/modules/m_opermotd.cpp b/src/modules/m_opermotd.cpp
index 5c107b6b1..fcd248b90 100644
--- a/src/modules/m_opermotd.cpp
+++ b/src/modules/m_opermotd.cpp
@@ -62,7 +62,10 @@ class CommandOpermotd : public Command
user->SendText(":%s 375 %s :- IRC Operators Message of the Day", servername.c_str(), user->nick.c_str());
for (int i=0; i != opermotd.FileSize(); i++)
- user->SendText(":%s 372 %s :- %s", servername.c_str(), user->nick.c_str(), opermotd.GetLine(i).c_str());
+ {
+ std::string line = opermotd.GetLine(i);
+ user->SendText(":%s 372 %s :- %s", servername.c_str(), user->nick.c_str(), line.c_str());
+ }
user->SendText(":%s 376 %s :- End of OPERMOTD", servername.c_str(), user->nick.c_str());
}
diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp
index 76d6ee469..c946193a8 100644
--- a/src/modules/m_override.cpp
+++ b/src/modules/m_override.cpp
@@ -158,7 +158,7 @@ class ModuleOverride : public Module
return MOD_RES_ALLOW;
}
- if (chan->IsModeSet('l') && (chan->GetUserCounter() >= atoi(chan->GetModeParameter('l').c_str())) && (CanOverride(user,"LIMIT")))
+ if (chan->IsModeSet('l') && (chan->GetUserCounter() >= ConvToInt(chan->GetModeParameter('l'))) && (CanOverride(user,"LIMIT")))
{
if (RequireKey && keygiven != "override")
{
diff --git a/src/modules/m_password_hash.cpp b/src/modules/m_password_hash.cpp
index aa2c21cd5..3a5070de0 100644
--- a/src/modules/m_password_hash.cpp
+++ b/src/modules/m_password_hash.cpp
@@ -57,8 +57,9 @@ class CommandMkpasswd : public Command
if (hp)
{
/* Now attempt to generate a hash */
+ std::string hexsum = hp->hexsum(stuff);
user->WriteServ("NOTICE %s :%s hashed password for %s is %s",
- user->nick.c_str(), algo.c_str(), stuff.c_str(), hp->hexsum(stuff).c_str());
+ user->nick.c_str(), algo.c_str(), stuff.c_str(), hexsum.c_str());
}
else
{
diff --git a/src/modules/m_redirect.cpp b/src/modules/m_redirect.cpp
index 6830f18ce..f21d43bf4 100644
--- a/src/modules/m_redirect.cpp
+++ b/src/modules/m_redirect.cpp
@@ -136,7 +136,7 @@ class ModuleRedirect : public Module
{
if (chan->IsModeSet('L') && chan->IsModeSet('l'))
{
- if (chan->GetUserCounter() >= atoi(chan->GetModeParameter('l').c_str()))
+ if (chan->GetUserCounter() >= ConvToInt(chan->GetModeParameter('l')))
{
std::string channel = chan->GetModeParameter('L');
diff --git a/src/modules/m_rline.cpp b/src/modules/m_rline.cpp
index 28fa891b6..551156732 100644
--- a/src/modules/m_rline.cpp
+++ b/src/modules/m_rline.cpp
@@ -80,8 +80,9 @@ class RLine : public XLine
ZLine* zl = new ZLine(ServerInstance->Time(), duration ? expiry - ServerInstance->Time() : 0, ServerInstance->Config->ServerName.c_str(), reason.c_str(), u->GetIPString());
if (ServerInstance->XLines->AddLine(zl, NULL))
{
+ std::string timestr = ServerInstance->TimeString(zl->expiry);
ServerInstance->SNO->WriteToSnoMask('x', "Z-line added due to R-line match on *@%s%s%s: %s",
- zl->ipaddr.c_str(), zl->duration ? " to expire on " : "", zl->duration ? ServerInstance->TimeString(zl->expiry).c_str() : "", zl->reason.c_str());
+ zl->ipaddr.c_str(), zl->duration ? " to expire on " : "", zl->duration ? timestr.c_str() : "", zl->reason.c_str());
added_zline = true;
}
else
@@ -179,7 +180,8 @@ class CommandRLine : public Command
else
{
time_t c_requires_crap = duration + ServerInstance->Time();
- ServerInstance->SNO->WriteToSnoMask('x', "%s added timed R-line for %s to expire on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
+ std::string timestr = ServerInstance->TimeString(c_requires_crap);
+ ServerInstance->SNO->WriteToSnoMask('x', "%s added timed R-line for %s to expire on %s: %s", user->nick.c_str(), parameters[0].c_str(), timestr.c_str(), parameters[2].c_str());
}
ServerInstance->XLines->ApplyLines();
diff --git a/src/modules/m_shun.cpp b/src/modules/m_shun.cpp
index 78046954c..399de24b8 100644
--- a/src/modules/m_shun.cpp
+++ b/src/modules/m_shun.cpp
@@ -151,8 +151,9 @@ class CommandShun : public Command
else
{
time_t c_requires_crap = duration + ServerInstance->Time();
+ std::string timestr = ServerInstance->TimeString(c_requires_crap);
ServerInstance->SNO->WriteToSnoMask('x', "%s added timed SHUN for %s to expire on %s: %s",
- user->nick.c_str(), target.c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), expr.c_str());
+ user->nick.c_str(), target.c_str(), timestr.c_str(), expr.c_str());
}
}
else
diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp
index 089d59931..81e4bc3d8 100644
--- a/src/modules/m_silence.cpp
+++ b/src/modules/m_silence.cpp
@@ -125,7 +125,8 @@ class CommandSilence : public Command
{
for (silencelist::const_iterator c = sl->begin(); c != sl->end(); c++)
{
- user->WriteNumeric(271, "%s %s %s %s",user->nick.c_str(), user->nick.c_str(),c->first.c_str(), DecompPattern(c->second).c_str());
+ std::string decomppattern = DecompPattern(c->second);
+ user->WriteNumeric(271, "%s %s %s %s",user->nick.c_str(), user->nick.c_str(),c->first.c_str(), decomppattern.c_str());
}
}
user->WriteNumeric(272, "%s :End of Silence List",user->nick.c_str());
@@ -161,6 +162,7 @@ class CommandSilence : public Command
if (action == '-')
{
+ std::string decomppattern = DecompPattern(pattern);
// fetch their silence list
silencelist* sl = ext.get(user);
// does it contain any entries and does it exist?
@@ -173,7 +175,7 @@ class CommandSilence : public Command
if (listitem == mask && i->second == pattern)
{
sl->erase(i);
- user->WriteNumeric(950, "%s %s :Removed %s %s from silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), DecompPattern(pattern).c_str());
+ user->WriteNumeric(950, "%s %s :Removed %s %s from silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str());
if (!sl->size())
{
ext.unset(user);
@@ -182,7 +184,7 @@ class CommandSilence : public Command
}
}
}
- user->WriteNumeric(952, "%s %s :%s %s does not exist on your silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), DecompPattern(pattern).c_str());
+ user->WriteNumeric(952, "%s %s :%s %s does not exist on your silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str());
}
else if (action == '+')
{
@@ -198,12 +200,14 @@ class CommandSilence : public Command
user->WriteNumeric(952, "%s %s :Your silence list is full",user->nick.c_str(), user->nick.c_str());
return CMD_FAILURE;
}
+
+ std::string decomppattern = DecompPattern(pattern);
for (silencelist::iterator n = sl->begin(); n != sl->end(); n++)
{
irc::string listitem = n->first.c_str();
if (listitem == mask && n->second == pattern)
{
- user->WriteNumeric(952, "%s %s :%s %s is already on your silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), DecompPattern(pattern).c_str());
+ user->WriteNumeric(952, "%s %s :%s %s is already on your silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str());
return CMD_FAILURE;
}
}
@@ -215,7 +219,7 @@ class CommandSilence : public Command
{
sl->push_back(silenceset(mask,pattern));
}
- user->WriteNumeric(951, "%s %s :Added %s %s to silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), DecompPattern(pattern).c_str());
+ user->WriteNumeric(951, "%s %s :Added %s %s to silence list",user->nick.c_str(), user->nick.c_str(), mask.c_str(), decomppattern.c_str());
return CMD_SUCCESS;
}
}
diff --git a/src/modules/m_spanningtree/addline.cpp b/src/modules/m_spanningtree/addline.cpp
index 5c3ad548d..7ee1a7ef1 100644
--- a/src/modules/m_spanningtree/addline.cpp
+++ b/src/modules/m_spanningtree/addline.cpp
@@ -30,7 +30,8 @@ bool TreeSocket::AddLine(const std::string &prefix, parameterlist &params)
{
if (params.size() < 6)
{
- ServerInstance->SNO->WriteToSnoMask('d', "%s sent me a malformed ADDLINE", MyRoot->GetName().c_str());
+ std::string servername = MyRoot->GetName();
+ ServerInstance->SNO->WriteToSnoMask('d', "%s sent me a malformed ADDLINE", servername.c_str());
return true;
}
@@ -44,7 +45,7 @@ bool TreeSocket::AddLine(const std::string &prefix, parameterlist &params)
{
TreeServer* t = Utils->FindServer(prefix);
if (t)
- setter = t->GetName().c_str();
+ setter = t->GetName();
}
if (!xlf)
@@ -68,8 +69,9 @@ bool TreeSocket::AddLine(const std::string &prefix, parameterlist &params)
{
if (xl->duration)
{
+ std::string timestr = ServerInstance->TimeString(xl->expiry);
ServerInstance->SNO->WriteToSnoMask('X',"%s added %s%s on %s to expire on %s: %s",setter.c_str(),params[0].c_str(),params[0].length() == 1 ? "-line" : "",
- params[1].c_str(),ServerInstance->TimeString(xl->expiry).c_str(),params[5].c_str());
+ params[1].c_str(), timestr.c_str(), params[5].c_str());
}
else
{
diff --git a/src/modules/m_spanningtree/delline.cpp b/src/modules/m_spanningtree/delline.cpp
index 5d88b4a0b..540ca5079 100644
--- a/src/modules/m_spanningtree/delline.cpp
+++ b/src/modules/m_spanningtree/delline.cpp
@@ -41,7 +41,7 @@ bool TreeSocket::DelLine(const std::string &prefix, parameterlist &params)
{
TreeServer* t = Utils->FindServer(prefix);
if (t)
- setter = t->GetName().c_str();
+ setter = t->GetName();
}
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp
index f639a748d..1ccfc43a5 100644
--- a/src/modules/m_spanningtree/main.cpp
+++ b/src/modules/m_spanningtree/main.cpp
@@ -99,7 +99,7 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
}
for (unsigned int q = 0; q < Current->ChildCount(); q++)
{
- if ((Current->GetChild(q)->Hidden) || ((Utils->HideULines) && (ServerInstance->ULine(Current->GetChild(q)->GetName().c_str()))))
+ if ((Current->GetChild(q)->Hidden) || ((Utils->HideULines) && (ServerInstance->ULine(Current->GetChild(q)->GetName()))))
{
if (IS_OPER(user))
{
@@ -112,13 +112,14 @@ void ModuleSpanningTree::ShowLinks(TreeServer* Current, User* user, int hops)
}
}
/* Don't display the line if its a uline, hide ulines is on, and the user isnt an oper */
- if ((Utils->HideULines) && (ServerInstance->ULine(Current->GetName().c_str())) && (!IS_OPER(user)))
+ if ((Utils->HideULines) && (ServerInstance->ULine(Current->GetName())) && (!IS_OPER(user)))
return;
/* Or if the server is hidden and they're not an oper */
else if ((Current->Hidden) && (!IS_OPER(user)))
return;
- user->WriteNumeric(364, "%s %s %s :%d %s", user->nick.c_str(),Current->GetName().c_str(),
+ std::string servername = Current->GetName();
+ user->WriteNumeric(364, "%s %s %s :%d %s", user->nick.c_str(), servername.c_str(),
(Utils->FlatLinks && (!IS_OPER(user))) ? ServerInstance->Config->ServerName.c_str() : Parent.c_str(),
(Utils->FlatLinks && (!IS_OPER(user))) ? 0 : hops,
Current->GetDesc().c_str());
@@ -162,7 +163,7 @@ restart:
for (server_hash::iterator i = Utils->serverlist.begin(); i != Utils->serverlist.end(); i++)
{
TreeServer *s = i->second;
-
+
if (s->GetSocket() && s->GetSocket()->GetLinkState() == DYING)
{
s->GetSocket()->Close();
@@ -215,7 +216,8 @@ restart:
if ((Utils->PingWarnTime) && (!s->Warned) && (curtime >= s->NextPingTime() - (Utils->PingFreq - Utils->PingWarnTime)) && (!s->AnsweredLastPing()))
{
/* The server hasnt responded, send a warning to opers */
- ServerInstance->SNO->WriteToSnoMask('l',"Server \002%s\002 has not responded to PING for %d seconds, high latency.", s->GetName().c_str(), Utils->PingWarnTime);
+ std::string servername = s->GetName();
+ ServerInstance->SNO->WriteToSnoMask('l',"Server \002%s\002 has not responded to PING for %d seconds, high latency.", servername.c_str(), Utils->PingWarnTime);
s->Warned = true;
}
}
@@ -411,7 +413,8 @@ ModResult ModuleSpanningTree::HandleConnect(const std::vector<std::string>& para
}
else
{
- RemoteMessage(user, "*** CONNECT: Server \002%s\002 already exists on the network and is connected via \002%s\002",x->Name.c_str(),CheckDupe->GetParent()->GetName().c_str());
+ std::string servername = CheckDupe->GetParent()->GetName();
+ RemoteMessage(user, "*** CONNECT: Server \002%s\002 already exists on the network and is connected via \002%s\002", x->Name.c_str(), servername.c_str());
return MOD_RES_DENY;
}
}
diff --git a/src/modules/m_spanningtree/netburst.cpp b/src/modules/m_spanningtree/netburst.cpp
index b1b55c986..8cd0dccd9 100644
--- a/src/modules/m_spanningtree/netburst.cpp
+++ b/src/modules/m_spanningtree/netburst.cpp
@@ -74,7 +74,9 @@ void TreeSocket::SendServers(TreeServer* Current, TreeServer* s, int hops)
TreeServer* recursive_server = Current->GetChild(q);
if (recursive_server != s)
{
- snprintf(command,1024,":%s SERVER %s * %d %s :%s",Current->GetName().c_str(),recursive_server->GetName().c_str(),hops,
+ std::string servername = Current->GetName();
+ std::string recursive_servername = recursive_server->GetName();
+ snprintf(command,1024,":%s SERVER %s * %d %s :%s", servername.c_str(), recursive_servername.c_str(), hops,
recursive_server->GetID().c_str(),
recursive_server->GetDesc().c_str());
this->WriteLine(command);
diff --git a/src/modules/m_spanningtree/override_map.cpp b/src/modules/m_spanningtree/override_map.cpp
index 83d969b3f..04fa4bcab 100644
--- a/src/modules/m_spanningtree/override_map.cpp
+++ b/src/modules/m_spanningtree/override_map.cpp
@@ -58,13 +58,14 @@ void ModuleSpanningTree::ShowMap(TreeServer* Current, User* user, int depth, int
memset(myname, ' ', depth);
int w = depth;
+ std::string servername = Current->GetName();
if (IS_OPER(user))
{
- w += snprintf(myname + depth, 99 - depth, "%s (%s)", Current->GetName().c_str(), Current->GetID().c_str());
+ w += snprintf(myname + depth, 99 - depth, "%s (%s)", servername.c_str(), Current->GetID().c_str());
}
else
{
- w += snprintf(myname + depth, 99 - depth, "%s", Current->GetName().c_str());
+ w += snprintf(myname + depth, 99 - depth, "%s", servername.c_str());
}
memset(myname + w, ' ', 100 - w);
if (w > maxnamew)
@@ -81,7 +82,7 @@ void ModuleSpanningTree::ShowMap(TreeServer* Current, User* user, int depth, int
if (!IS_OPER(user)) {
if (child->Hidden)
continue;
- if ((Utils->HideULines) && (ServerInstance->ULine(child->GetName().c_str())))
+ if ((Utils->HideULines) && (ServerInstance->ULine(child->GetName())))
continue;
}
ShowMap(child, user, depth, line, names, maxnamew, stats);
diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp
index 3e916544b..6582ba060 100644
--- a/src/modules/m_spanningtree/treesocket1.cpp
+++ b/src/modules/m_spanningtree/treesocket1.cpp
@@ -157,8 +157,9 @@ void TreeSocket::SendError(const std::string &errormessage)
*/
void TreeSocket::SquitServer(std::string &from, TreeServer* Current, int& num_lost_servers, int& num_lost_users)
{
+ std::string servername = Current->GetName();
ServerInstance->Logs->Log("m_spanningtree",DEBUG,"SquitServer for %s from %s",
- Current->GetName().c_str(), from.c_str());
+ servername.c_str(), from.c_str());
/* recursively squit the servers attached to 'Current'.
* We're going backwards so we don't remove users
* while we still need them ;)
diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp
index 0a0c22e39..a06ff3a67 100644
--- a/src/modules/m_spanningtree/treesocket2.cpp
+++ b/src/modules/m_spanningtree/treesocket2.cpp
@@ -491,6 +491,9 @@ void TreeSocket::Close()
time_t server_uptime = ServerInstance->Time() - this->age;
if (server_uptime)
- ServerInstance->SNO->WriteGlobalSno('l', "Connection to '\2%s\2' was established for %s", linkID.c_str(), Utils->Creator->TimeToStr(server_uptime).c_str());
+ {
+ std::string timestr = Utils->Creator->TimeToStr(server_uptime);
+ ServerInstance->SNO->WriteGlobalSno('l', "Connection to '\2%s\2' was established for %s", linkID.c_str(), timestr.c_str());
+ }
}
}
diff --git a/src/modules/m_svshold.cpp b/src/modules/m_svshold.cpp
index 3b920b466..a2b072921 100644
--- a/src/modules/m_svshold.cpp
+++ b/src/modules/m_svshold.cpp
@@ -136,7 +136,8 @@ class CommandSvshold : public Command
else
{
time_t c_requires_crap = duration + ServerInstance->Time();
- ServerInstance->SNO->WriteGlobalSno('x', "%s added timed SVSHOLD for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), ServerInstance->TimeString(c_requires_crap).c_str(), parameters[2].c_str());
+ std::string timestr = ServerInstance->TimeString(c_requires_crap);
+ ServerInstance->SNO->WriteGlobalSno('x', "%s added timed SVSHOLD for %s, expires on %s: %s", user->nick.c_str(), parameters[0].c_str(), timestr.c_str(), parameters[2].c_str());
}
}
else
diff --git a/src/server.cpp b/src/server.cpp
index b7e58c56b..30d204aa4 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -70,7 +70,10 @@ std::string InspIRCd::GetVersionString(bool operstring)
{
char versiondata[MAXBUF];
if (operstring)
- snprintf(versiondata,MAXBUF,"%s %s :%s [%s,%s,%s]",VERSION,Config->ServerName.c_str(),SYSTEM,REVISION,SE->GetName().c_str(),Config->sid.c_str());
+ {
+ std::string sename = SE->GetName();
+ snprintf(versiondata,MAXBUF,"%s %s :%s [%s,%s,%s]",VERSION, Config->ServerName.c_str(), SYSTEM,REVISION, sename.c_str(), Config->sid.c_str());
+ }
else
snprintf(versiondata,MAXBUF,"%s %s :%s",BRANCH,Config->ServerName.c_str(),Config->CustomVersion.c_str());
return versiondata;
diff --git a/src/socket.cpp b/src/socket.cpp
index 8c7ec97d8..6fc7b13f8 100644
--- a/src/socket.cpp
+++ b/src/socket.cpp
@@ -313,7 +313,7 @@ irc::sockets::cidr_mask::cidr_mask(const std::string& mask)
}
else
{
- int range = atoi(mask.substr(bits_chars + 1).c_str());
+ int range = ConvToInt(mask.substr(bits_chars + 1));
irc::sockets::aptosa(mask.substr(0, bits_chars), 0, sa);
sa2cidr(*this, sa, range);
}
diff --git a/src/users.cpp b/src/users.cpp
index a4af8914b..29c670a66 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -789,7 +789,11 @@ void LocalUser::FullConnect()
this->WriteNumeric(RPL_WELCOME, "%s :Welcome to the %s IRC Network %s!%s@%s",this->nick.c_str(), ServerInstance->Config->Network.c_str(), this->nick.c_str(), this->ident.c_str(), this->host.c_str());
this->WriteNumeric(RPL_YOURHOSTIS, "%s :Your host is %s, running version %s",this->nick.c_str(),ServerInstance->Config->ServerName.c_str(),BRANCH);
this->WriteNumeric(RPL_SERVERCREATED, "%s :This server was created %s %s", this->nick.c_str(), __TIME__, __DATE__);
- this->WriteNumeric(RPL_SERVERVERSION, "%s %s %s %s %s %s", this->nick.c_str(), ServerInstance->Config->ServerName.c_str(), BRANCH, ServerInstance->Modes->UserModeList().c_str(), ServerInstance->Modes->ChannelModeList().c_str(), ServerInstance->Modes->ParaModeList().c_str());
+
+ std::string umlist = ServerInstance->Modes->UserModeList();
+ std::string cmlist = ServerInstance->Modes->ChannelModeList();
+ std::string pmlist = ServerInstance->Modes->ParaModeList();
+ this->WriteNumeric(RPL_SERVERVERSION, "%s %s %s %s %s %s", this->nick.c_str(), ServerInstance->Config->ServerName.c_str(), BRANCH, umlist.c_str(), cmlist.c_str(), pmlist.c_str());
ServerInstance->Config->Send005(this);
this->WriteNumeric(RPL_YOURUUID, "%s %s :your unique ID", this->nick.c_str(), this->uuid.c_str());
diff --git a/src/whois.cpp b/src/whois.cpp
index 7ef79aa3f..bec9c7ea9 100644
--- a/src/whois.cpp
+++ b/src/whois.cpp
@@ -50,7 +50,8 @@ void InspIRCd::DoWhois(User* user, User* dest,unsigned long signon, unsigned lon
}
else
{
- this->SendWhoisLine(user, dest, 312, "%s %s %s :%s",user->nick.c_str(), dest->nick.c_str(), dest->server.c_str(), this->GetServerDescription(dest->server).c_str());
+ std::string serverdesc = GetServerDescription(dest->server);
+ this->SendWhoisLine(user, dest, 312, "%s %s %s :%s",user->nick.c_str(), dest->nick.c_str(), dest->server.c_str(), serverdesc.c_str());
}
if (IS_AWAY(dest))