mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 10:39:02 -04:00
Backport of relevant changes from 02859be56d43bcece02aab350e02bc95ed1bf446.
Fix undefined behavior caused by referencing the buffer returned by std::string::c_str() when the object is temporary.
This commit is contained in:
parent
0566869d89
commit
56641d0499
@ -921,7 +921,7 @@ class CoreExport InspIRCd : public classbase
|
||||
|
||||
/** Return a time_t as a human-readable string.
|
||||
*/
|
||||
std::string TimeString(time_t curtime);
|
||||
const std::string &TimeString(time_t curtime);
|
||||
|
||||
/** Begin execution of the server.
|
||||
* NOTE: this function NEVER returns. Internally,
|
||||
|
@ -29,7 +29,8 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
|
||||
|
||||
CmdResult CommandVersion::Handle (const std::vector<std::string>&, User *user)
|
||||
{
|
||||
user->WriteNumeric(RPL_VERSION, "%s :%s",user->nick.c_str(),ServerInstance->GetVersionString().c_str());
|
||||
std::string ver = ServerInstance->GetVersionString();
|
||||
user->WriteNumeric(RPL_VERSION, "%s :%s",user->nick.c_str(),ver.c_str());
|
||||
ServerInstance->Config->Send005(user);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
@ -435,9 +435,11 @@ bool InspIRCd::SilentULine(const char* sserver)
|
||||
else return false;
|
||||
}
|
||||
|
||||
std::string InspIRCd::TimeString(time_t curtime)
|
||||
const std::string &InspIRCd::TimeString(time_t curtime)
|
||||
{
|
||||
return std::string(ctime(&curtime),24);
|
||||
static std::string buf;
|
||||
buf.assign(ctime(&curtime), 24);
|
||||
return buf;
|
||||
}
|
||||
|
||||
// You should only pass a single character to this.
|
||||
|
@ -180,7 +180,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 user_password = user->password.substr(0, pos);
|
||||
res = ldap_search_ext_s(conn, base.c_str(), searchscope, user_password.c_str(), NULL, 0, NULL, NULL, NULL, 0, &msg);
|
||||
|
||||
if (res)
|
||||
{
|
||||
|
@ -136,8 +136,8 @@ 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();
|
||||
irc::string pattern = assign(MyConf->ReadValue("badword","text",index));
|
||||
irc::string replace = assign(MyConf->ReadValue("badword","replace",index));
|
||||
censors[pattern] = replace;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,8 @@ public:
|
||||
{
|
||||
if (iter->first == user)
|
||||
{
|
||||
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('J').c_str());
|
||||
std::string modeparam = chan->GetModeParameter('J');
|
||||
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(), modeparam.c_str());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,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 pattern = DecompPattern(c->second);
|
||||
user->WriteNumeric(271, "%s %s %s %s",user->nick.c_str(), user->nick.c_str(),c->first.c_str(), pattern.c_str());
|
||||
}
|
||||
}
|
||||
user->WriteNumeric(272, "%s :End of Silence List",user->nick.c_str());
|
||||
|
Loading…
x
Reference in New Issue
Block a user