summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2010-04-11 00:29:07 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2010-04-11 00:29:07 +0000
commit1e9de0c7f146ec00d2dd6ee4cb9d86860a03ea9f (patch)
treec653f724f60fa569c62a8b44eab4c147d52f1b40
parent626afff37d1a31b2427700ac5a1dbdb32171afbc (diff)
Return MOD_STOP in various places where the user executing the command had been killed, fixes a crash if a user gets killed for too many invalid passwords
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2885 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r--include/extern.h2
-rw-r--r--src/actions.c11
-rw-r--r--src/core/ns_ghost.c3
-rw-r--r--src/core/ns_group.c3
-rw-r--r--src/core/ns_identify.c3
-rw-r--r--src/core/ns_recover.c3
-rw-r--r--src/core/ns_release.c3
7 files changed, 19 insertions, 9 deletions
diff --git a/include/extern.h b/include/extern.h
index fb432f44f..2b8b8ca0e 100644
--- a/include/extern.h
+++ b/include/extern.h
@@ -35,7 +35,7 @@ E IRCDProto *ircdproto;
/**** actions.c ****/
E void kill_user(const std::string &source, const std::string &user, const std::string &reason);
-E void bad_password(User *u);
+E bool bad_password(User *u);
E void sqline(const std::string &mask, const std::string &reason);
E void common_unban(ChannelInfo *ci, const std::string &nick);
diff --git a/src/actions.c b/src/actions.c
index 39c646cce..eea1906ca 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -20,21 +20,26 @@
* Note a bad password attempt for the given user. If they've used up
* their limit, toss them off.
* @param u the User to check
- * @return void
+ * @return true if the user was killed, otherwise false
*/
-void bad_password(User *u)
+bool bad_password(User *u)
{
time_t now = time(NULL);
if (!u || !Config.BadPassLimit)
- return;
+ return false;
if (Config.BadPassTimeout > 0 && u->invalid_pw_time > 0 && u->invalid_pw_time < now - Config.BadPassTimeout)
u->invalid_pw_count = 0;
++u->invalid_pw_count;
u->invalid_pw_time = now;
if (u->invalid_pw_count >= Config.BadPassLimit)
+ {
kill_user("", u->nick, "Too many invalid passwords");
+ return true;
+ }
+
+ return false;
}
/*************************************************************************/
diff --git a/src/core/ns_ghost.c b/src/core/ns_ghost.c
index 49c36b303..72b02efae 100644
--- a/src/core/ns_ghost.c
+++ b/src/core/ns_ghost.c
@@ -54,7 +54,8 @@ class CommandNSGhost : public Command
if (!res)
{
Alog() << Config.s_NickServ << ": GHOST: invalid password for " << nick << " by " << u->GetMask();
- bad_password(u);
+ if (bad_password(u))
+ return MOD_STOP;
}
}
}
diff --git a/src/core/ns_group.c b/src/core/ns_group.c
index 65b655ec7..bdf80d38d 100644
--- a/src/core/ns_group.c
+++ b/src/core/ns_group.c
@@ -89,7 +89,8 @@ class CommandNSGroup : public Command
{
Alog() << Config.s_NickServ << ": Failed GROUP for " << u->GetMask() << " (invalid password)";
notice_lang(Config.s_NickServ, u, PASSWORD_INCORRECT);
- bad_password(u);
+ if (bad_password(u))
+ return MOD_STOP;
}
else
{
diff --git a/src/core/ns_identify.c b/src/core/ns_identify.c
index a0a217677..f16b5e84c 100644
--- a/src/core/ns_identify.c
+++ b/src/core/ns_identify.c
@@ -54,7 +54,8 @@ class CommandNSIdentify : public Command
{
Alog() << Config.s_NickServ << ": Failed IDENTIFY for " << u->nick << "!" << u->GetIdent() << "@" << u->host;
notice_lang(Config.s_NickServ, u, PASSWORD_INCORRECT);
- bad_password(u);
+ if (bad_password(u))
+ return MOD_STOP;
}
else if (res == -1)
notice_lang(Config.s_NickServ, u, NICK_IDENTIFY_FAILED);
diff --git a/src/core/ns_recover.c b/src/core/ns_recover.c
index 0937d6891..3a0a9cedd 100644
--- a/src/core/ns_recover.c
+++ b/src/core/ns_recover.c
@@ -62,7 +62,8 @@ class CommandNSRecover : public Command
if (!res)
{
Alog() << Config.s_NickServ << ": RECOVER: invalid password for " << nick << " by " << u->GetMask();
- bad_password(u);
+ if (bad_password(u))
+ return MOD_STOP;
}
}
}
diff --git a/src/core/ns_release.c b/src/core/ns_release.c
index 7ec6f85ee..a4169ecda 100644
--- a/src/core/ns_release.c
+++ b/src/core/ns_release.c
@@ -51,7 +51,8 @@ class CommandNSRelease : public Command
if (!res)
{
Alog() << Config.s_NickServ << ": RELEASE: invalid password for " << nick << " by " << u->GetMask();
- bad_password(u);
+ if (bad_password(u))
+ return MOD_STOP;
}
}
}