From: Michael Poole Date: Fri, 1 Jun 2012 02:41:28 +0000 (-0400) Subject: Add more G-line length tests. Resolves SF#2985922. X-Git-Url: http://git.pk910.de/?p=ircu2.10.12-pk.git;a=commitdiff_plain;h=72b0c799c590095ad78de705f36e9553bd41fa67 Add more G-line length tests. Resolves SF#2985922. Also remove the extra space noted in the same bug report. --- diff --git a/ChangeLog b/ChangeLog index ac1643b..f3e6f8e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012-05-31 Michael Poole + + * ircd/gline.c (gline_add): Add length checks for badchan and + realname G-lines, comparable to the existing check for traditional + G-lines. + + * ircd/s_err.c (ERR_LONGMASK): Remove extra space in format string. + 2012-05-31 Michael Poole * ircd/m_server.c (check_loop_and_lh): Mention the mechanism used diff --git a/ircd/gline.c b/ircd/gline.c index 4f95526..9c3d297 100644 --- a/ircd/gline.c +++ b/ircd/gline.c @@ -24,6 +24,7 @@ #include "config.h" #include "gline.h" +#include "channel.h" #include "client.h" #include "ircd.h" #include "ircd_alloc.h" @@ -448,13 +449,21 @@ gline_add(struct Client *cptr, struct Client *sptr, char *userhost, if (*userhost == '#' || *userhost == '&') { if ((flags & GLINE_LOCAL) && !HasPriv(sptr, PRIV_LOCAL_BADCHAN)) return send_reply(sptr, ERR_NOPRIVILEGES); + /* Allow maximum channel name length, plus margin for wildcards. */ + if (strlen(userhost+1) >= CHANNELLEN + 6) + return send_reply(sptr, ERR_LONGMASK); flags |= GLINE_BADCHAN; user = userhost; host = NULL; } else if (*userhost == '$') { switch (userhost[1]) { - case 'R': flags |= GLINE_REALNAME; break; + case 'R': + /* Allow REALLEN for the real name, plus margin for wildcards. */ + if (strlen(userhost+2) >= REALLEN + 6) + return send_reply(sptr, ERR_LONGMASK); + flags |= GLINE_REALNAME; + break; default: /* uh, what to do here? */ /* The answer, my dear Watson, is we throw a protocol_violation() diff --git a/ircd/s_err.c b/ircd/s_err.c index b05affb..dc45c2e 100644 --- a/ircd/s_err.c +++ b/ircd/s_err.c @@ -1068,7 +1068,7 @@ static Numeric replyTable[] = { /* 517 */ { ERR_DISABLED, "%s :Command disabled.", "517" }, /* 518 */ - { ERR_LONGMASK, " :Mask is too long", "518" }, + { ERR_LONGMASK, ":Mask is too long", "518" }, /* 519 */ { ERR_TOOMANYUSERS, "%d :Too many users affected by mask", "519" }, /* 520 */