summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgeniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b <geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2008-01-26 10:41:11 +0000
committergeniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b <geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2008-01-26 10:41:11 +0000
commit3e977708beb1cd13a0c66f2bdfb6f1303ab5e588 (patch)
tree62662db003ea16d35252cf22cbcf5536c1990bef /src
parent439c66311a0c04c5e447c86b23a5359d9adb37b3 (diff)
BUILD : 1.7.21 (1362) BUGS : 841 NOTES : Fixed memleaks in hs_setall
git-svn-id: svn://svn.anope.org/anope/trunk@1362 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1077 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r--src/core/hs_setall.c38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/core/hs_setall.c b/src/core/hs_setall.c
index ca11e46ba..c3ec12fe2 100644
--- a/src/core/hs_setall.c
+++ b/src/core/hs_setall.c
@@ -72,7 +72,7 @@ int do_setall(User * u)
{
char *nick = strtok(NULL, " ");
- char *rawhostmask = strtok(NULL, " ");
+ char *rawhostmask = sstrdup(strtok(NULL, " "));
char *hostmask = smalloc(HOSTMAX);
NickAlias *na;
@@ -83,29 +83,47 @@ int do_setall(User * u)
if (!nick || !rawhostmask) {
notice_lang(s_HostServ, u, HOST_SETALL_SYNTAX, s_HostServ);
+ free(rawhostmask);
+ free(hostmask);
return MOD_CONT;
}
vIdent = myStrGetOnlyToken(rawhostmask, '@', 0); /* Get the first substring, @ as delimiter */
if (vIdent) {
+ free(rawhostmask);
rawhostmask = myStrGetTokenRemainder(rawhostmask, '@', 1); /* get the remaining string */
if (!rawhostmask) {
notice_lang(s_HostServ, u, HOST_SETALL_SYNTAX, s_HostServ);
+ if (vIdent)
+ free(vIdent);
+ free(hostmask);
return MOD_CONT;
}
if (strlen(vIdent) > USERMAX - 1) {
notice_lang(s_HostServ, u, HOST_SET_IDENTTOOLONG, USERMAX);
+ if (vIdent)
+ free(vIdent);
+ free(rawhostmask);
+ free(hostmask);
return MOD_CONT;
} else {
for (s = vIdent; *s; s++) {
if (!isvalidchar(*s)) {
notice_lang(s_HostServ, u, HOST_SET_IDENT_ERROR);
+ if (vIdent)
+ free(vIdent);
+ free(rawhostmask);
+ free(hostmask);
return MOD_CONT;
}
}
}
if (!ircd->vident) {
notice_lang(s_HostServ, u, HOST_NO_VIDENT);
+ if (vIdent)
+ free(vIdent);
+ free(rawhostmask);
+ free(hostmask);
return MOD_CONT;
}
}
@@ -114,12 +132,19 @@ int do_setall(User * u)
snprintf(hostmask, HOSTMAX - 1, "%s", rawhostmask);
else {
notice_lang(s_HostServ, u, HOST_SET_TOOLONG, HOSTMAX);
+ if (vIdent)
+ free(vIdent);
+ free(rawhostmask);
+ free(hostmask);
return MOD_CONT;
}
if (!isValidHost(hostmask, 3)) {
notice_lang(s_HostServ, u, HOST_SET_ERROR);
- free(hostmask);
+ if (vIdent)
+ free(vIdent);
+ free(rawhostmask);
+ free(hostmask);
return MOD_CONT;
}
@@ -128,7 +153,10 @@ int do_setall(User * u)
if ((na = findnick(nick))) {
if (na->status & NS_VERBOTEN) {
notice_lang(s_HostServ, u, NICK_X_FORBIDDEN, nick);
- free(hostmask);
+ if (vIdent)
+ free(vIdent);
+ free(rawhostmask);
+ free(hostmask);
return MOD_CONT;
}
if (vIdent && ircd->vident) {
@@ -146,7 +174,9 @@ int do_setall(User * u)
} else {
notice_lang(s_HostServ, u, HOST_NOREG, nick);
}
-
+ if (vIdent)
+ free(vIdent);
+ free(rawhostmask);
free(hostmask);
return MOD_CONT;
}