diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-08-27 18:33:32 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-08-27 18:33:32 +0200 |
commit | 25ab5612f2ed8f0163c338740abd9f133af89356 (patch) | |
tree | 54f966dcdb994970fac4ad873c903ff3c834767b /src/commands | |
parent | 261d5bb566f6383efea99e73c933a2af6f408341 (diff) |
Fix crash caused by passing a large integer to ctime()
In addition to verifying the return value of localtime(), correct tm_year if it is out of bounds
Reported by @JDowny
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/cmd_whowas.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/commands/cmd_whowas.cpp b/src/commands/cmd_whowas.cpp index 17a779ec3..3a6444b45 100644 --- a/src/commands/cmd_whowas.cpp +++ b/src/commands/cmd_whowas.cpp @@ -58,14 +58,6 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use for (whowas_set::iterator ux = grp->begin(); ux != grp->end(); ux++) { WhoWasGroup* u = *ux; - time_t rawtime = u->signon; - tm *timeinfo; - char b[25]; - - timeinfo = localtime(&rawtime); - - strncpy(b,asctime(timeinfo),24); - b[24] = 0; user->WriteNumeric(314, "%s %s %s %s * :%s",user->nick.c_str(),parameters[0].c_str(), u->ident.c_str(),u->dhost.c_str(),u->gecos.c_str()); @@ -74,10 +66,11 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use user->WriteNumeric(379, "%s %s :was connecting from *@%s", user->nick.c_str(), parameters[0].c_str(), u->host.c_str()); + std::string signon = ServerInstance->TimeString(u->signon); if (!ServerInstance->Config->HideWhoisServer.empty() && !user->HasPrivPermission("servers/auspex")) - user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), ServerInstance->Config->HideWhoisServer.c_str(), b); + user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), ServerInstance->Config->HideWhoisServer.c_str(), signon.c_str()); else - user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), u->server.c_str(), b); + user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), u->server.c_str(), signon.c_str()); } } else |