[eggheads-patches] PATCH: floodfix.patch

Fabian Knittel fknittel at gmx.de
Sun Oct 17 22:44:26 CST 1999


[ floodfix.patch ]

The channel flood protection routine attempted to punish
non-existant channel members, which caused SEGVs in a few
places. I thought I had fixed this before, but overlooked
a few cases to the end of the function.

The new behaviour is to exit the function as soon as we
notice that the member doesn't exist. This is a common case
on irc networks which have services, e.g. on Dalnet.

In addition, a few sentkick checks were missing in there.

Fabian
-------------- next part --------------
diff -urN eggdrop1.3~/doc/UPDATES1.3 eggdrop1.3/doc/UPDATES1.3
--- eggdrop1.3~/doc/UPDATES1.3	Fri Oct 15 11:06:19 1999
+++ eggdrop1.3/doc/UPDATES1.3	Sun Oct 17 10:42:13 1999
@@ -4,6 +4,8 @@
 
 1.3.29
 Foundby   Fixedby   What....
+IpAddress Fabian    flood protection attempted to punish non-existant channel
+		    members and IRC services
           Cybah	    strncpy() being used on buffers without terminating them.
 Tothwolf  Fabian    stopped userfile parsing funcs from messing with ~ and `
           rtc       language files were being installed twice
diff -urN eggdrop1.3~/src/mod/irc.mod/chan.c eggdrop1.3/src/mod/irc.mod/chan.c
--- eggdrop1.3~/src/mod/irc.mod/chan.c	Fri Oct 15 11:06:20 1999
+++ eggdrop1.3/src/mod/irc.mod/chan.c	Sun Oct 17 10:39:21 1999
@@ -117,12 +117,15 @@
   struct userrec *u;
   memberlist *m;
   int thr = 0, lapse = 0;
-  struct flag_record fr =
-  {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
+  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
 
   if (!chan || (which < 0) || (which >= FLOOD_CHAN_MAX))
     return 0;
   m = ismember(chan, floodnick); 
+  /* let's not fight against non-existant channel members and
+   * IRC services like ChanServ  (Fabian) */
+  if (!m)
+    return 0;
   get_user_flagrec(get_user_by_host(from), &fr, chan->name);
   context;
   if (glob_bot(fr) ||
@@ -220,7 +223,7 @@
     case FLOOD_NOTICE:
     case FLOOD_CTCP:
       /* flooding chan! either by public or notice */
-      if (m && me_op(chan)) {
+      if (me_op(chan) && !chan_sentkick(m)) {
 	putlog(LOG_MODES, chan->name, IRC_FLOODKICK, floodnick);
 	dprintf(DP_MODE, "KICK %s %s :%s\n", chan->name, floodnick,
 		CHAN_FLOOD);
@@ -264,7 +267,7 @@
 	}
       return 1;
     case FLOOD_KICK:
-      if (me_op(chan)) {
+      if (me_op(chan) && !chan_sentkick(m)) {
 	putlog(LOG_MODES, chan->name, "Kicking %s, for mass kick.", floodnick);
 	dprintf(DP_MODE, "KICK %s %s :%s\n", chan->name, floodnick,
 		IRC_MASSKICK);
@@ -272,7 +275,7 @@
       }
     return 1;
     case FLOOD_DEOP:
-      if (me_op(chan)) {
+      if (me_op(chan) && !chan_sentkick(m)) {
 	putlog(LOG_MODES, chan->name,
 	       CHAN_MASSDEOP, CHAN_MASSDEOP_ARGS); 
 	dprintf(DP_MODE, "KICK %s %s :%s\n",
@@ -772,8 +775,7 @@
 static int got352or4(struct chanset_t *chan, char *user, char *host,
 		     char *nick, char *flags)
 {
-  struct flag_record fr =
-  {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
+  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
   char userhost[UHOSTLEN], *p;
   memberlist *m;
   int waschanop;
@@ -935,8 +937,7 @@
   char s[UHOSTLEN], *ban, *who, *chname;
   struct chanset_t *chan;
   struct userrec *u;
-  struct flag_record fr =
-  {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
+  struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0};
 
   newsplit(&msg);
   chname = newsplit(&msg);
@@ -1315,8 +1316,7 @@
 static void do_embedded_mode(struct chanset_t *chan, char *nick,
 			     memberlist * m, char *mode)
 {
-  struct flag_record fr =
-  {0, 0, 0, 0, 0, 0};
+  struct flag_record fr = {0, 0, 0, 0, 0, 0};
   int servidx = findanyidx(serv);
 
   while (*mode) {
@@ -1533,7 +1533,7 @@
 	    if (ok && !chan_sentkick(m)) {
 	      dprintf(DP_SERVER, "KICK %s %s :%s\n", chname, m->nick,
 		      IRC_YOUREBANNED);
-	      m->flags |= SENTKICK;    
+	      m->flags |= SENTKICK;
             }
 	  }
 	}


More information about the Patches mailing list