Fix silence bugs found by coekie and ban application bug found by xplora.
[ircu2.10.12-pk.git] / ircd / m_silence.c
index 1be8a4b25218ace34081980b53f2634833b6fdae..97069d4d9552de5ec0360873ee48e63bd5abd0fd 100644 (file)
@@ -60,7 +60,7 @@
  * @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;
@@ -84,7 +84,7 @@ apply_silence(struct Client *sptr, const char *mask)
   }
 
   /* Make the silence, set flags, and apply it. */
-  sile = make_ban(mask);
+  sile = make_ban(pretty_mask(mask));
   sile->flags |= flags;
   return apply_ban(&cli_user(sptr)->silence, sile, 1) ? NULL : sile;
 }
@@ -118,11 +118,13 @@ forward_silences(struct Client *sptr, char *silences, struct Client *dest)
     maxlength = maxsiles * feature_int(FEAT_AVBANLEN);
     siles = totlength = 0;
     /* Count number of current silences and their total length. */
+    plast = &cli_user(sptr)->silence;
     for (sile = cli_user(sptr)->silence; sile; sile = sile->next) {
       if (sile->flags & (BAN_OVERLAPPED | BAN_ADD | BAN_DEL))
         continue;
       siles++;
       totlength += strlen(sile->banstr);
+      plast = &sile->next;
     }
     for (ii = jj = 0; ii < ac_count; ++ii) {
       sile = accepted[ii];
@@ -132,12 +134,16 @@ forward_silences(struct Client *sptr, char *silences, struct Client *dest)
       if (!(sile->flags & (BAN_OVERLAPPED | BAN_DEL))) {
         slen = strlen(sile->banstr);
         if ((siles >= maxsiles) || (totlength + slen >= maxlength)) {
+          *plast = NULL;
+          if (MyUser(sptr))
+            send_reply(sptr, ERR_SILELISTFULL, accepted[ii]->banstr);
           free_ban(accepted[ii]);
           continue;
         }
         /* Update counts. */
         siles++;
         totlength += slen;
+        plast = &sile->next;
       }
       /* Store the update. */
       accepted[jj++] = sile;