From 1c7c7573beaeaa20d077e57bbed5bee3e8624fd4 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Sun, 15 Jan 2006 14:42:16 +0000 Subject: [PATCH] - Fixed some more memleaks, thanks to valgrind. --- Changes | 1 + src/modules/m_user.c | 10 +++++++--- src/s_bsd.c | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Changes b/Changes index dd0d894cb..acdea8177 100644 --- a/Changes +++ b/Changes @@ -960,3 +960,4 @@ - Made the charsys mismatch during linking a warning instead of an error (temp. fix, until a good solution is implemented without false positives). - Crashbug fix for above +- Fixed some more memleaks, thanks to valgrind. diff --git a/src/modules/m_user.c b/src/modules/m_user.c index b9f967947..49bf46d97 100644 --- a/src/modules/m_user.c +++ b/src/modules/m_user.c @@ -82,6 +82,9 @@ DLLFUNC int MOD_UNLOAD(m_user)(int module_unload) ** parv[2] = client host name (used only from other servers) ** parv[3] = server host name (used only from other servers) ** parv[4] = users real name info +** +** NOTE: Be advised that multiple USER messages are possible, +** hence, always check if a certain struct is already allocated... -- Syzop */ DLLFUNC CMD_FUNC(m_user) { @@ -169,7 +172,7 @@ DLLFUNC CMD_FUNC(m_user) } else user->server = find_or_add(server); - strncpyzt(user->realhost, host, sizeof(user->realhost)); + strlcpy(user->realhost, host, sizeof(user->realhost)); goto user_finish; } @@ -195,11 +198,12 @@ DLLFUNC CMD_FUNC(m_user) * which seemed bad. Not to say this is much better ;p. -- Syzop */ strncpyzt(user->realhost, Inet_ia2p(&sptr->ip), sizeof(user->realhost)); - user->ip_str = strdup(Inet_ia2p(&sptr->ip)); + if (!user->ip_str) + user->ip_str = strdup(Inet_ia2p(&sptr->ip)); user->server = me_hash; user_finish: user->servicestamp = sstamp; - strncpyzt(sptr->info, realname, sizeof(sptr->info)); + strlcpy(sptr->info, realname, sizeof(sptr->info)); if (sptr->name[0] && (IsServer(cptr) ? 1 : IsNotSpoof(sptr))) /* NICK and no-spoof already received, now we have USER... */ { diff --git a/src/s_bsd.c b/src/s_bsd.c index bb897436a..8e3d2fa60 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -734,6 +734,7 @@ static int check_init(aClient *cptr, char *sockn, size_t size) if (inet_netof(sk.SIN_ADDR) == IN_LOOPBACKNET) #endif { + unreal_free_hostent(cptr->hostp); cptr->hostp = NULL; strncpyzt(sockn, "localhost", HOSTLEN); }