Avoid improper reuse of a va_list.
[ircu2.10.12-pk.git] / ircd / m_silence.c
index f8ee5c3f83a4ac6615a41bd9bb69e9a6bd51dc52..4530d6bcb7d84c96e983c7768fe0f29fb745b71b 100644 (file)
  * @return The new ban entry on success, NULL on failure.
  */
 static struct Ban *
-apply_silence(struct Client *sptr, const char *mask)
+apply_silence(struct Client *sptr, char *mask)
 {
   struct Ban *sile;
   int flags;
+  char orig_mask[NICKLEN+USERLEN+HOSTLEN+3];
 
   assert(mask && mask[0]);
 
@@ -83,9 +84,22 @@ apply_silence(struct Client *sptr, const char *mask)
     mask++;
   }
 
-  /* Make the silence, set flags, and apply it. */
-  sile = make_ban(mask);
+  /* Make the silence and set additional flags. */
+  ircd_strncpy(orig_mask, mask, sizeof(orig_mask) - 1);
+  sile = make_ban(pretty_mask(mask));
   sile->flags |= flags;
+
+  /* If they're a local user trying to ban too broad a mask, forbid it. */
+  if (MyUser(sptr)
+      && (sile->flags & BAN_IPMASK)
+      && sile->addrbits > 0
+      && sile->addrbits < (irc_in_addr_is_ipv4(&sile->address) ? 112 : 32)) {
+    send_reply(sptr, ERR_MASKTOOWIDE, orig_mask);
+    free_ban(sile);
+    return NULL;
+  }
+
+  /* Apply it to the silence list. */
   return apply_ban(&cli_user(sptr)->silence, sile, 1) ? NULL : sile;
 }