Просмотр исходного кода

* No longer initializing dcc[] union as chat_info for bots (might cause segfaults, but should be quickly found)

svn: 2363
Bryan Drewery 21 лет назад
Родитель
Сommit
e102d8a557
3 измененных файлов с 24 добавлено и 12 удалено
  1. 17 11
      src/dcc.c
  2. 3 1
      src/dcc.h
  3. 4 0
      src/enclink.h

+ 17 - 11
src/dcc.c

@@ -877,10 +877,13 @@ append_line(int idx, char *line)
 static void
 static void
 out_dcc_general(int idx, char *buf, void *x)
 out_dcc_general(int idx, char *buf, void *x)
 {
 {
-  register struct chat_info *p = (struct chat_info *) x;
   char *y = buf;
   char *y = buf;
 
 
-  strip_mirc_codes(p->strip_flags, buf);
+  if (dcc[idx].type == &DCC_CHAT) {
+    register struct chat_info *p = (struct chat_info *) x;
+
+    strip_mirc_codes(p->strip_flags, buf);
+  }
   if (dcc[idx].status & STAT_TELNET)
   if (dcc[idx].status & STAT_TELNET)
     y = add_cr(buf);
     y = add_cr(buf);
   if (dcc[idx].status & STAT_PAGE)
   if (dcc[idx].status & STAT_PAGE)
@@ -1520,8 +1523,8 @@ kill_dupwait(int idx, void *x)
   register struct dupwait_info *p = (struct dupwait_info *) x;
   register struct dupwait_info *p = (struct dupwait_info *) x;
 
 
   if (p) {
   if (p) {
-    if (p->chat && DCC_CHAT.kill)
-      DCC_CHAT.kill(idx, p->chat);
+//    if (p->chat && DCC_CHAT.kill)
+//      DCC_CHAT.kill(idx, p->chat);
     free(p);
     free(p);
   }
   }
 }
 }
@@ -1617,15 +1620,20 @@ dcc_telnet_id(int idx, char *buf, int atr)
       lostdcc(idx);
       lostdcc(idx);
       return;
       return;
     } else if (in_chain(dcc[idx].nick)) {
     } else if (in_chain(dcc[idx].nick)) {
-      struct chat_info *ci = dcc[idx].u.chat;
+//      struct chat_info *ci = dcc[idx].u.chat;
 
 
       dcc[idx].type = &DCC_DUPWAIT;
       dcc[idx].type = &DCC_DUPWAIT;
       dcc[idx].u.dupwait = (struct dupwait_info *) my_calloc(1, sizeof(struct dupwait_info));
       dcc[idx].u.dupwait = (struct dupwait_info *) my_calloc(1, sizeof(struct dupwait_info));
-      dcc[idx].u.dupwait->chat = ci;
+//      dcc[idx].u.dupwait->chat = ci;
       dcc[idx].u.dupwait->atr = atr;
       dcc[idx].u.dupwait->atr = atr;
       return;
       return;
     }
     }
+  } else {
+    //bots dont need this
+    dcc[idx].u.chat = (struct chat_info *) my_calloc(1, sizeof(struct chat_info));
+    strcpy(dcc[idx].u.chat->con_chan, chanset ? chanset->dname : "*");
   }
   }
+
   dcc_telnet_pass(idx, atr);
   dcc_telnet_pass(idx, atr);
 }
 }
 
 
@@ -1637,7 +1645,7 @@ dcc_telnet_pass(int idx, int atr)
   get_user_flagrec(dcc[idx].user, &fr, NULL);
   get_user_flagrec(dcc[idx].user, &fr, NULL);
 
 
   /* No password set? */
   /* No password set? */
-  if (!glob_bot(fr) && (u_pass_match(dcc[idx].user, "-"))) {
+  if (!dcc[idx].user->bot && (u_pass_match(dcc[idx].user, "-"))) {
     dprintf(idx, "Can't telnet until you have a password set.\r\n");
     dprintf(idx, "Can't telnet until you have a password set.\r\n");
     putlog(LOG_MISC, "*", DCC_NOPASS, dcc[idx].nick, dcc[idx].host);
     putlog(LOG_MISC, "*", DCC_NOPASS, dcc[idx].nick, dcc[idx].host);
     killsock(dcc[idx].sock);
     killsock(dcc[idx].sock);
@@ -1646,10 +1654,10 @@ dcc_telnet_pass(int idx, int atr)
   }
   }
 
 
   if (dcc[idx].type == &DCC_DUPWAIT) {
   if (dcc[idx].type == &DCC_DUPWAIT) {
-    struct chat_info *ci = dcc[idx].u.dupwait->chat;
+//    struct chat_info *ci = dcc[idx].u.dupwait->chat;
 
 
     free(dcc[idx].u.dupwait);
     free(dcc[idx].u.dupwait);
-    dcc[idx].u.chat = ci;
+//    dcc[idx].u.chat = ci;
   }
   }
   dcc[idx].type = &DCC_CHAT_PASS;
   dcc[idx].type = &DCC_CHAT_PASS;
   dcc[idx].timeval = now;
   dcc[idx].timeval = now;
@@ -1913,7 +1921,6 @@ dcc_telnet_got_ident(int i, char *host)
   sockoptions(dcc[i].sock, EGG_OPTION_UNSET, SOCK_BUFFER);
   sockoptions(dcc[i].sock, EGG_OPTION_UNSET, SOCK_BUFFER);
 
 
   dcc[i].type = &DCC_TELNET_ID;
   dcc[i].type = &DCC_TELNET_ID;
-  dcc[i].u.chat = (struct chat_info *) my_calloc(1, sizeof(struct chat_info));
 
 
   /* Copy acceptable-nick/host mask */
   /* Copy acceptable-nick/host mask */
   dcc[i].status = (STAT_TELNET | STAT_ECHO | STAT_COLOR | STAT_BANNER | STAT_CHANNELS | STAT_BOTS | STAT_WHOM);
   dcc[i].status = (STAT_TELNET | STAT_ECHO | STAT_COLOR | STAT_BANNER | STAT_CHANNELS | STAT_BOTS | STAT_WHOM);
@@ -1921,7 +1928,6 @@ dcc_telnet_got_ident(int i, char *host)
   /* Copy acceptable-nick/host mask */
   /* Copy acceptable-nick/host mask */
   strlcpy(dcc[i].nick, dcc[idx].host, HANDLEN);
   strlcpy(dcc[i].nick, dcc[idx].host, HANDLEN);
   dcc[i].timeval = now;
   dcc[i].timeval = now;
-  strcpy(dcc[i].u.chat->con_chan, chanset ? chanset->dname : "*");
   /* This is so we dont tell someone doing a portscan anything
   /* This is so we dont tell someone doing a portscan anything
    * about ourselves. <cybah>
    * about ourselves. <cybah>
    */
    */

+ 3 - 1
src/dcc.h

@@ -6,6 +6,7 @@
 #endif
 #endif
 
 
 #include "types.h"
 #include "types.h"
+#include "enclink.h"
 #include "crypt.h"
 #include "crypt.h"
 #include "eggdrop.h"
 #include "eggdrop.h"
 #include "src/mod/server.mod/server.h"
 #include "src/mod/server.mod/server.h"
@@ -35,6 +36,7 @@ struct dcc_t {
     struct bot_info *bot;
     struct bot_info *bot;
     struct relay_info *relay;
     struct relay_info *relay;
     struct dupwait_info *dupwait;
     struct dupwait_info *dupwait;
+    struct enc_link_dcc *enc;
     int ident_sock;
     int ident_sock;
     void *other;
     void *other;
   } u;                          /* Special use depending on type        */
   } u;                          /* Special use depending on type        */
@@ -127,7 +129,7 @@ struct relay_info {
 };
 };
 
 
 struct dupwait_info {
 struct dupwait_info {
-  struct chat_info *chat;       /* holds current chat data              */
+//  struct chat_info *chat;       /* holds current chat data              */
   int atr;                      /* the bots attributes                  */
   int atr;                      /* the bots attributes                  */
 };
 };
 
 

+ 4 - 0
src/enclink.h

@@ -30,6 +30,10 @@ struct enc_link {
   void (*parse) (int, int, char *);
   void (*parse) (int, int, char *);
 };
 };
 
 
+struct enc_link_dcc {
+  struct enc_link *method;
+  int status;
+};
 
 
 extern struct enc_link enclink[];
 extern struct enc_link enclink[];