Browse Source

* Some misc fixes, hopefully to fix this pesky dead socket stuff

svn: 1490
Bryan Drewery 21 years ago
parent
commit
25cd6464fc
3 changed files with 10 additions and 9 deletions
  1. 3 3
      src/adns.c
  2. 3 4
      src/dcc.c
  3. 4 2
      src/net.c

+ 3 - 3
src/adns.c

@@ -748,9 +748,9 @@ static void parse_reply(char *response, int nbytes)
 {
 	dns_header_t header;
 	dns_rr_t reply;
-	dns_query_t *q, *prev;
-	char result[512];
-	unsigned char *ptr;
+	dns_query_t *q = NULL, *prev = NULL;
+	char result[512] = "";
+	unsigned char *ptr = NULL;
 	int i;
 
 	ptr = (unsigned char *) response;

+ 3 - 4
src/dcc.c

@@ -1307,13 +1307,13 @@ static void dcc_telnet_dns_callback(int id, void *client_data, const char *ip, c
   dcc[i].timeval = now;
   dcc[i].u.ident_sock = dcc[idx].sock;
   
-  sock = open_telnet((char *) ip, 113);
-
   if (hosts)
     putlog(LOG_MISC, "*", "Telnet connection: %s[%s]/%d", dcc[i].host, ip, dcc[i].port);
   else
     putlog(LOG_MISC, "*", "Telnet connection: %s/%d", dcc[i].host, dcc[i].port);
 
+  sock = open_telnet((char *) ip, 113);
+
   char s[UHOSTLEN] = "";
 
   if (sock < 0) {
@@ -1555,9 +1555,8 @@ dcc_telnet_pass(int idx, int atr)
   if (glob_bot(fr))
     ok = 1;
   if (!ok) {
-    struct chat_info *ci;
+    struct chat_info *ci = dcc[idx].u.chat;
 
-    ci = dcc[idx].u.chat;
     dcc[idx].u.file = (struct file_info *) calloc(1, sizeof(struct file_info));
     dcc[idx].u.file->chat = ci;
   }

+ 4 - 2
src/net.c

@@ -373,7 +373,7 @@ int allocsock(int sock, int options)
       socklist[i].okey[0] = 0;
       socklist[i].ikey[0] = 0;
       socks_total++;
-      sdprintf("allocsock(%d) = %d", sock, i);
+      sdprintf("allocsock(%d) = %d", i, sock);
       return i;
     }
   }
@@ -1572,8 +1572,10 @@ void tputs(register int z, char *s, size_t len)
 
 int findanysnum(register int sock)
 {
+  register int i = 0;
+
   if (sock != -1)
-    for (int i = 0; i < socks_total; i++)
+    for (i = 0; i < socks_total; i++)
       if ((socklist[i].sock == sock) && !(socklist[i].flags & SOCK_UNUSED))
         return i;