summaryrefslogtreecommitdiff
path: root/src/commands/cmd_whowas.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-02 00:47:45 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-02 00:47:45 +0000
commit94bb5343b1464cbec9f58ee9d90a3deae3ac5308 (patch)
treeb472a590d1536d9dc23c47aa381429d00d16ed81 /src/commands/cmd_whowas.cpp
parent2455cd671f4dbc017cf7bb76fb7b29e9f95f3b40 (diff)
Remove calls to strdup() in core, it is not better than std::string
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11623 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/commands/cmd_whowas.cpp')
-rw-r--r--src/commands/cmd_whowas.cpp27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/commands/cmd_whowas.cpp b/src/commands/cmd_whowas.cpp
index 71b228070..e5542d16e 100644
--- a/src/commands/cmd_whowas.cpp
+++ b/src/commands/cmd_whowas.cpp
@@ -55,18 +55,19 @@ CmdResult CommandWhowas::Handle (const std::vector<std::string>& parameters, Use
WhoWasGroup* u = *ux;
time_t rawtime = u->signon;
tm *timeinfo;
- char b[MAXBUF];
+ char b[25];
timeinfo = localtime(&rawtime);
- /* XXX - 'b' could be only 25 chars long and then strlcpy() would terminate it for us too? */
- strlcpy(b,asctime(timeinfo),MAXBUF);
+ 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,u->dhost,u->gecos);
+ 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());
if (user->HasPrivPermission("users/auspex"))
- user->WriteNumeric(379, "%s %s :was connecting from *@%s", user->nick.c_str(), parameters[0].c_str(), u->host);
+ user->WriteNumeric(379, "%s %s :was connecting from *@%s",
+ user->nick.c_str(), parameters[0].c_str(), u->host.c_str());
if (*ServerInstance->Config->HideWhoisServer && !user->HasPrivPermission("servers/auspex"))
user->WriteNumeric(312, "%s %s %s :%s",user->nick.c_str(),parameters[0].c_str(), ServerInstance->Config->HideWhoisServer, b);
@@ -315,25 +316,13 @@ CommandWhowas::~CommandWhowas()
}
}
-WhoWasGroup::WhoWasGroup(User* user) : host(NULL), dhost(NULL), ident(NULL), server(NULL), gecos(NULL), signon(user->signon)
+WhoWasGroup::WhoWasGroup(User* user) : host(user->host), dhost(user->dhost), ident(user->ident),
+ server(user->server), gecos(user->fullname), signon(user->signon)
{
- this->host = strdup(user->host.c_str());
- this->dhost = strdup(user->dhost.c_str());
- this->ident = strdup(user->ident.c_str());
- this->server = user->server;
- this->gecos = strdup(user->fullname.c_str());
}
WhoWasGroup::~WhoWasGroup()
{
- if (host)
- free(host);
- if (dhost)
- free(dhost);
- if (ident)
- free(ident);
- if (gecos)
- free(gecos);
}
/* every hour, run this function which removes all entries older than Config->WhoWasMaxKeep */