Jelajahi Sumber

* Fixed a dcctable list 'gap'/'leak'

svn: 1618
Bryan Drewery 21 tahun lalu
induk
melakukan
40224bbdf0
4 mengubah file dengan 15 tambahan dan 3 penghapusan
  1. 1 0
      doc/UPDATES
  2. 8 3
      src/botnet.c
  3. 5 0
      src/dccutil.c
  4. 1 0
      src/dccutil.h

+ 1 - 0
doc/UPDATES

@@ -17,6 +17,7 @@ This is a summary of ChangeLog basically.
 * cmd_conf now correctly writes new data to binary (not tested)
 * Fixed stdin/stdout/stderr not being closed when bot is forked into background.
 * Fixed cmd_dns not displaying results.
+* Fixed dcctable list 'leak' (no shift, leaves gaps, now dcclist is shifted only if gap at end)
 
 1.2
 * No longer displaying SALTS on ./bin -v

+ 8 - 3
src/botnet.c

@@ -1599,12 +1599,13 @@ struct dcc_table DCC_PRE_RELAY =
  */
 void check_botnet_pings()
 {
-  int i;
-  int bots, users;
+  int i, bots, users, top_index = 0;
   tand_t *bot = NULL;
 
   for (i = 0; i < dcc_total; i++) {
-    if (dcc[i].type && dcc[i].type == &DCC_BOT) {
+   if (dcc[i].type) {
+     top_index = i;
+    if (dcc[i].type == &DCC_BOT) {
       if (dcc[i].status & STAT_LEAF) {
         tand_t *via = findbot(dcc[i].nick);
 
@@ -1655,7 +1656,11 @@ void check_botnet_pings()
         dcc[i].status |= STAT_PINGED;
       }
     }
+   }
   }
+
+  if (top_index != (dcc_total - 1))
+    trim_dcclist(top_index);
 }
 
 void zapfbot(int idx)

+ 5 - 0
src/dccutil.c

@@ -362,6 +362,11 @@ dcc_chatter(int idx)
   }
 }
 
+void trim_dcclist(int top_index)
+{
+  dcc_total = top_index + 1;    
+}
+
 /* Mark an entry as lost and deconstruct it's contents. It will be securely
  * removed from the dcc list in the main loop.
  */

+ 1 - 0
src/dccutil.h

@@ -31,6 +31,7 @@ void dprintf(int, const char *, ...) __attribute__((format(printf, 2, 3)));
 void chatout(const char *, ...) __attribute__((format(printf, 1, 2)));
 void chanout_but(int, int, const char *, ...) __attribute__((format(printf, 3, 4)));
 void dcc_chatter(int);
+void trim_dcclist(int);
 void lostdcc(int);
 void makepass(char *);
 void tell_dcc(int);