Jelajahi Sumber

* Added valid_idx()

svn: 1479
Bryan Drewery 21 tahun lalu
induk
melakukan
9587fd9d2a
3 mengubah file dengan 9 tambahan dan 1 penghapusan
  1. 1 1
      src/dcc.c
  2. 7 0
      src/dccutil.c
  3. 1 0
      src/dccutil.h

+ 1 - 1
src/dcc.c

@@ -1280,7 +1280,7 @@ static void dcc_telnet_dns_callback(void *client_data, const char *ip, char **ho
     return;
   }
 
-  if (idx < 0 || !dcc[idx].type) {
+  if (!valid_idx(idx)) {
     putlog(LOG_BOTS, "*", "Lost listening socket while resolving %s", dcc[i].host);
     killsock(dcc[i].sock);
     lostdcc(i);

+ 7 - 0
src/dccutil.c

@@ -767,3 +767,10 @@ void identd_close()
     }
   }
 }
+
+bool valid_idx(int idx)
+{
+  if ((idx == -1) || (idx >= dcc_total) || (!dcc[idx].type))
+    return 0;
+  return 1;
+}

+ 1 - 0
src/dccutil.h

@@ -47,6 +47,7 @@ int detect_dcc_flood(time_t *, struct chat_info *, int);
 void identd_open();
 void identd_close();
 port_t listen_all(port_t, bool);
+bool valid_idx(int);
 
 extern int		max_dcc;
 extern time_t		connect_timeout;