Add more G-line length tests. Resolves SF#2985922.
authorMichael Poole <mdpoole@troilus.org>
Fri, 1 Jun 2012 02:41:28 +0000 (22:41 -0400)
committerMichael Poole <mdpoole@troilus.org>
Fri, 1 Jun 2012 02:41:28 +0000 (22:41 -0400)
Also remove the extra space noted in the same bug report.

ChangeLog
ircd/gline.c
ircd/s_err.c

index ac1643be6f6d610c081c951378bad89ff27bc1e9..f3e6f8e849ae6dca417c4e5183a25118a543485d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2012-05-31  Michael Poole <mdpoole@troilus.org>
+
+       * 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 <mdpoole@troilus.org>
 
        * ircd/m_server.c (check_loop_and_lh): Mention the mechanism used
index 4f95526448498e3b968574027a68d3e2ffff953f..9c3d2970e24df6a078e4c976cb94c64a2b7d8d36 100644 (file)
@@ -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()
index b05affba32348760cd8b7b0001e1ee8f43abdac2..dc45c2eab768055e98103d27eca55ab7f2986896 100644 (file)
@@ -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 */