From 25ab5612f2ed8f0163c338740abd9f133af89356 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Tue, 27 Aug 2013 18:33:32 +0200 Subject: 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 --- src/commands/cmd_whowas.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'src/commands/cmd_whowas.cpp') 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& 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& 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 -- cgit v1.2.3