]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix more undefined behavior caused by referencing the returned buffer by std::string...
authorattilamolnar <attilamolnar@hush.com>
Sat, 29 Sep 2012 23:10:57 +0000 (01:10 +0200)
committerattilamolnar <attilamolnar@hush.com>
Sun, 30 Sep 2012 01:04:07 +0000 (03:04 +0200)
See 83c7cc45daf6fb1f8c36f15297a4657e45a34e88

35 files changed:
src/channels.cpp
src/commands/cmd_eline.cpp
src/commands/cmd_gline.cpp
src/commands/cmd_kline.cpp
src/commands/cmd_qline.cpp
src/commands/cmd_version.cpp
src/commands/cmd_zline.cpp
src/dns.cpp
src/modmanager_dynamic.cpp
src/modules/extra/m_ldapauth.cpp
src/modules/m_cban.cpp
src/modules/m_censor.cpp
src/modules/m_connectban.cpp
src/modules/m_dnsbl.cpp
src/modules/m_kicknorejoin.cpp
src/modules/m_operlog.cpp
src/modules/m_opermotd.cpp
src/modules/m_override.cpp
src/modules/m_password_hash.cpp
src/modules/m_redirect.cpp
src/modules/m_rline.cpp
src/modules/m_shun.cpp
src/modules/m_silence.cpp
src/modules/m_spanningtree/addline.cpp
src/modules/m_spanningtree/delline.cpp
src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/netburst.cpp
src/modules/m_spanningtree/override_map.cpp
src/modules/m_spanningtree/treesocket1.cpp
src/modules/m_spanningtree/treesocket2.cpp
src/modules/m_svshold.cpp
src/server.cpp
src/socket.cpp
src/users.cpp
src/whois.cpp

index c265171b5ce85c6ced4e78d30a440a3ed4f8eb28..855fd0e150e0297d2658b9e5bd0f353b080e8b7f 100644 (file)
@@ -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;
index 15487bd8e984d73356c77a19df183db20cd4c5b1..43eb678eeefe3ef8416037755f79bc52f5ce08a2 100644 (file)
@@ -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
index f4f962569761e5462c43ef5b8a84f8c3a91605c6..430256be8f52d9644db02a3cfd734cb0991892b0 100644 (file)
@@ -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();
index 6c2789557f43597c76d489bcc1c18fb50f650d18..b1f5f62db8959dfacc65777c4bfb91c7412a9bca 100644 (file)
@@ -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();
index 64ba1a78b3281d47f24371b2b351becd0ea5d8f0..3118798e6cfc2ea52b086f602a52eee419c2c597 100644 (file)
@@ -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();
                }
index 6fae329bd06f17a41211235ace24c780e8ba1816..7620197fd40053e96ecb5588d7299dece2e8063f 100644 (file)
@@ -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;
 }
index cee7f616d5dfbd2f4467445a37bf813904f04696..3e940a9bd42ad19f936150ae197bc63e20c34940 100644 (file)
@@ -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();
                }
index 17641c585be5de1d320c868a9c669dfc9861d2df..1c23710a4ea34da779a7cc49bf2aacfdd89463ca 100644 (file)
@@ -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,"");
        }
 
index e613508df8d333f503ff1412cb41179d5838413c..e0d744b3ac4981c36953f2879fd8909b84c84244 100644 (file)
@@ -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
index 0f1ca74d7834172e92bd853a28c48ce5598b317b..1b6a3a0d9aa591dd3560479287583a67ed6d509d 100644 (file)
@@ -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)
                                {
index 92f97158ecf123758a39f992d41293d2eed2ccc0..0157a4addc87e7376930a16d0249e73d347bbbeb 100644 (file)
@@ -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
index 5e832cc8b6007e12c6197d91ebd97c45caefe355..bbf061f7ea3cd6ec719959e2d3e09e4321377ba3 100644 (file)
@@ -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());
                }
        }
 
index 00452a8f28c9e24c6689c01ab682ebcc06b36713..aebe9a4ca8a3eaa5ccbd6e45882e75d402633de0 100644 (file)
@@ -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);
                        }
                }
index 645949006978ba43a1e03cfef3d6c4d2996a759a..52500dec89b4775df1ccec1e469497793a579d15 100644 (file)
@@ -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.";
                                }
 
index 520e5b005b96baa4024ccea7896f85d1ed5cc80f..7abb9be7bbab4f09f123c06268d0d801e8876303 100644 (file)
@@ -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));
                }
        }
 
index cc533dbf5de7cb54e211fe85c77d205279f1ffd5..d8006d9d5267d1fa8a68a03b52e9b9ad4e98028a 100644 (file)
@@ -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;
index 5c107b6b190fbefd6843423675a043c14e8810c3..fcd248b90a6c6cb1644f55dcae05755d6440caa7 100644 (file)
@@ -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());
        }
index 76d6ee469635d0c4fbbcfd852f86664996cd7a4e..c946193a84d5d5812fc8c482a38abed9860448b8 100644 (file)
@@ -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")
                                        {
index aa2c21cd56abfd8b7ed5a51148de011811731d1d..3a5070de05ff59ee3f9c4103ded5069cbd4349ad 100644 (file)
@@ -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
                {
index 6830f18cee1724f6cd0192848b08662b6a3a17b4..f21d43bf449ea5eb8cfea4c4e4a9fe5515de7782 100644 (file)
@@ -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');
 
index 28fa891b61cd1854134c73979a03107640d46bbc..551156732dc9838cdd81e7b1fc7631d94e864110 100644 (file)
@@ -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();
index 78046954ce251958a148f58c16e223cfc5a4e412..399de24b86de4cd6b735457685dedc10a781139e 100644 (file)
@@ -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
index 089d599316dd277bb75dc6a437d271fe0905e787..81e4bc3d8d9714c55c5cea7748db2949bd82acde 100644 (file)
@@ -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;
                        }
                }
index 5c3ad548d4cebd5c967f09805bb61803e18c0d60..7ee1a7ef1b0d5d57882d50aa1b2da96957d35f13 100644 (file)
@@ -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
                {
index 5d88b4a0bdf88e8b39a96edbf7766c8e8cd83dfc..540ca50792dcf25a4e822fd4dd6182731f0771ed 100644 (file)
@@ -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();
        }
 
 
index f639a748d5e411917cdae7b3d74bd5ff119f960d..1ccfc43a5ec49a17b4e591cb2f6e2f53dd689aef 100644 (file)
@@ -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;
                        }
                }
index b1b55c986d699a116c5e9dd87610e394d8c9b427..8cd0dccd9ae78b7591d487108b2475b60290fd02 100644 (file)
@@ -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);
index 83d969b3ff4bb191cfbda0e2d677f285f83ee455..04fa4bcab31b53a61aaaab3b6b5e9abd3c25c102 100644 (file)
@@ -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);
index 3e916544bfbadc1ddf7cbd628faa12ce768a332b..6582ba0606d599ab18e2e30aafdd16342c861630 100644 (file)
@@ -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 ;)
index 0a0c22e39cf1cc1d95c685b8d069564e886c7d05..a06ff3a67248464aeb3646527fbfb1e9948fe451 100644 (file)
@@ -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());
+               }
        }
 }
index 3b920b466149828c5d1eba95bd83635a2861ca92..a2b072921fd30eef4a8dca908ad8cb43e2d71aed 100644 (file)
@@ -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
index b7e58c56be00155db48b22d8ea62c7c097dd5138..30d204aa48596a7871a133beca82b714ec505b24 100644 (file)
@@ -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;
index 8c7ec97d85d5c4d5c1b02ae50553b34d95708e6e..6fc7b13f8fc967e25bf248d8c08137ac9dd1b187 100644 (file)
@@ -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);
        }
index a4af8914b70a217a651728488fecc3d5ec9740de..29c670a66fb0dffe2bc8d78a40df39d53be75deb 100644 (file)
@@ -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());
index 7ef79aa3ffdec2311fb18b9ebf8013781f2ba356..bec9c7ea9e0e44824e09eacbf0d303fda43280cd 100644 (file)
@@ -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))