ソースを参照

* Ported [2518] to 1.2.9 (fixes #189)

svn: 2616
Bryan Drewery 20 年 前
コミット
b81cc8cdf4
3 ファイル変更8 行追加6 行削除
  1. 1 0
      doc/UPDATES
  2. 6 5
      src/dccutil.c
  3. 1 1
      src/dccutil.h

+ 1 - 0
doc/UPDATES

@@ -41,6 +41,7 @@ Lines prefixed with '-' were disabled before release and are not finished, or ar
 * Fixed an invalid killsock error in sharing.
 * Fixed chanset 'flood-*' not working correctly. (#69)
 * Fixed cmd_rehash killing hubs. And revised help for 'rehash'. (#186)
+* Fixed a bug in the listen code, which caused a segfault in /ctcp chat (a few other places too) (#189)
 
 1.2.8
 * Fixed [bot]* cmds depending on case of botnicks.

+ 6 - 5
src/dccutil.c

@@ -827,16 +827,16 @@ do_boot(int idx, char *by, char *reason)
   return;
 }
 
-port_t
+int
 listen_all(port_t lport, bool off)
 {
-  int idx = (-1);
+  int idx = -1;
   port_t port, realport;
 
 #ifdef USE_IPV6
   int i6 = 0;
 #endif /* USE_IPV6 */
-  int i;
+  int i = 0, ii = 0;
   struct portmap *pmap = NULL, *pold = NULL;
 
   port = realport = lport;
@@ -846,7 +846,7 @@ listen_all(port_t lport, bool off)
       break;
     }
 
-  for (int ii = 0; ii < dcc_total; ii++) {
+  for (ii = 0; ii < dcc_total; ii++) {
     if (dcc[ii].type && (dcc[ii].type == &DCC_TELNET) && (dcc[ii].port == port)) {
       idx = ii;
 
@@ -885,6 +885,7 @@ listen_all(port_t lport, bool off)
         putlog(LOG_ERRORS, "*", "Can't open IPv6 listening port %d - %s", port,
                i6 == -1 ? "it's taken." : "couldn't assign ip.");
       } else {
+        /* now setup ipv4/ipv6 listening port */
         idx = new_dcc(&DCC_TELNET, 0);
         dcc[idx].addr = 0L;
         strcpy(dcc[idx].host6, myipstr(6));
@@ -903,7 +904,7 @@ listen_all(port_t lport, bool off)
         putlog(LOG_ERRORS, "*", "Can't open IPv4 listening port %d - %s", port,
                i == -1 ? "it's taken." : "couldn't assign ip.");
       } else {
-        idx = (-1);             /* now setup ipv4 listening port */
+        /* now setup ipv4 listening port */
         idx = new_dcc(&DCC_TELNET, 0);
         dcc[idx].addr = iptolong(getmyip());
         dcc[idx].port = port;

+ 1 - 1
src/dccutil.h

@@ -53,7 +53,7 @@ void do_boot(int, char *, char *);
 int detect_dcc_flood(time_t *, struct chat_info *, int);
 void identd_open();
 void identd_close();
-port_t listen_all(port_t, bool);
+int listen_all(port_t, bool);
 bool valid_idx(int);
 int dcc_read(FILE *);
 void dcc_write(FILE *, int);