summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/botserv.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/botserv.c b/src/botserv.c
index 418e029d6..4b5ce1561 100644
--- a/src/botserv.c
+++ b/src/botserv.c
@@ -185,15 +185,19 @@ void botmsgs(User * u, BotInfo * bi, char *buf)
*
*/
-void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
+void botchanmsgs(User * u, ChannelInfo * ci, char *buff)
{
int c;
int16 cstatus = 0;
- char *cmd;
+ char *cmd, *buf;
UserData *ud;
+
+ buf = sstrdup(buff);
- if (!u)
+ if (!u) {
+ free(buf);
return;
+ }
/* Answer to ping if needed, without breaking the buffer. */
if (!strnicmp(buf, "\1PING", 5))
@@ -239,6 +243,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
if ((ci->botflags & BS_KICK_BOLDS) && strchr(buf, 2)) {
check_ban(ci, u, TTB_BOLDS);
bot_kick(ci, u, BOT_REASON_BOLD);
+ free(buf);
return;
}
@@ -246,6 +251,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
if ((ci->botflags & BS_KICK_COLORS) && strchr(buf, 3)) {
check_ban(ci, u, TTB_COLORS);
bot_kick(ci, u, BOT_REASON_COLOR);
+ free(buf);
return;
}
@@ -253,6 +259,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
if ((ci->botflags & BS_KICK_REVERSES) && strchr(buf, 22)) {
check_ban(ci, u, TTB_REVERSES);
bot_kick(ci, u, BOT_REASON_REVERSE);
+ free(buf);
return;
}
@@ -260,6 +267,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
if ((ci->botflags & BS_KICK_UNDERLINES) && strchr(buf, 31)) {
check_ban(ci, u, TTB_UNDERLINES);
bot_kick(ci, u, BOT_REASON_UNDERLINE);
+ free(buf);
return;
}
@@ -277,6 +285,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
if (i >= ci->capsmin && i * 100 / c >= ci->capspercent) {
check_ban(ci, u, TTB_CAPS);
bot_kick(ci, u, BOT_REASON_CAPS);
+ free(buf);
return;
}
}
@@ -396,6 +405,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
bot_kick(ci, u, BOT_REASON_BADWORD_GENTLE);
else
bot_kick(ci, u, BOT_REASON_BADWORD, bw->word);
+ free(buf);
return;
}
}
@@ -410,8 +420,10 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
time_t now = time(NULL);
ud = get_user_data(ci->c, u);
- if (!ud)
+ if (!ud) {
+ free(buf);
return;
+ }
if (now - ud->last_start > ci->floodsecs) {
ud->last_start = time(NULL);
@@ -422,6 +434,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
if (ud->lines >= ci->floodlines) {
check_ban(ci, u, TTB_FLOOD);
bot_kick(ci, u, BOT_REASON_FLOOD);
+ free(buf);
return;
}
}
@@ -429,9 +442,10 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
/* Repeat kicker */
if (ci->botflags & BS_KICK_REPEAT) {
ud = get_user_data(ci->c, u);
- if (!ud)
+ if (!ud) {
+ free(buf);
return;
-
+ }
if (ud->lastline && stricmp(ud->lastline, buf)) {
free(ud->lastline);
ud->lastline = sstrdup(buf);
@@ -445,6 +459,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
if (ud->times >= ci->repeattimes) {
check_ban(ci, u, TTB_REPEAT);
bot_kick(ci, u, BOT_REASON_REPEAT);
+ free(buf);
return;
}
}
@@ -453,6 +468,7 @@ void botchanmsgs(User * u, ChannelInfo * ci, char *buf)
/* return if the user is on the ignore list */
if (get_ignore(u->nick) != NULL) {
+ free(buf);
return;
}