[eggheads-patches] PATCH: open_telnet_raw.patch

Fabian Knittel fknittel at gmx.de
Thu Oct 7 16:41:28 CST 1999


[ open_telnet_raw.patch ]

This patch changes the behaviour of net:open_telnet_raw() to not
close the given socket itsself. The old behaviour was causing
"Attempt to kill un-allocated socket 5 !!" messages, because the
calling functions killsocked the socket themself again. The only
clean way was to change open_telnet_raw's behaviour. open_telnet()
is now emulating the old behaviour and open_telnet_dcc had the
same problem as open_telnet_raw.

This bug is rather different than the one fixed in linkfix, as it
doesn't really cause any problems apart from displaying that msg.

The bug was reported and partly analysed by Eule :)

Fabian
-------------- next part --------------
diff -urN eggdrop1.3~/doc/UPDATES1.3 eggdrop1.3/doc/UPDATES1.3
--- eggdrop1.3~/doc/UPDATES1.3	Thu Oct  7 22:45:06 1999
+++ eggdrop1.3/doc/UPDATES1.3	Thu Oct  7 22:45:26 1999
@@ -4,6 +4,8 @@
 
 1.3.29
 Foundby   Fixedby   What....
+Eule	  Fabian    open_telnet_raw and open_telnet_dcc were still causing
+		    un-allocated socket messages
 SuperS	  Fabian    minor fixes for os4 compiling
 	  Fabian    main() wasn't removing unknown sockets correctly
 	  Fabian    probably fixes the "un-allocated socket" problem
diff -urN eggdrop1.3~/src/mod/share.mod/share.c eggdrop1.3/src/mod/share.mod/share.c
--- eggdrop1.3~/src/mod/share.mod/share.c	Tue Oct  5 11:26:38 1999
+++ eggdrop1.3/src/mod/share.mod/share.c	Thu Oct  7 21:28:44 1999
@@ -930,6 +930,7 @@
     ip = newsplit(&par);
     port = newsplit(&par);
     if (open_telnet_dcc(sock, ip, port) < 0) {
+      killsock(sock);
       putlog(LOG_MISC, "*", "Asynchronous connection failed!");
       dprintf(idx, "s e Can't connect to you!\n");
       zapfbot(idx);
diff -urN eggdrop1.3~/src/net.c eggdrop1.3/src/net.c
--- eggdrop1.3~/src/net.c	Tue Oct  5 11:26:45 1999
+++ eggdrop1.3/src/net.c	Thu Oct  7 21:30:28 1999
@@ -359,10 +359,8 @@
 
   name.sin_family = AF_INET;
   name.sin_addr.s_addr = (myip[0] ? getmyip() : INADDR_ANY);
-  if (bind(sock, (struct sockaddr *) &name, sizeof(name)) < 0) {
-    killsock(sock);
+  if (bind(sock, (struct sockaddr *) &name, sizeof(name)) < 0)
     return -1;
-  }
   bzero((char *) &name, sizeof(struct sockaddr_in));
 
   name.sin_family = AF_INET;
@@ -379,10 +377,8 @@
     } else {
       hp = NULL;
     }
-    if (hp == NULL) {
-      killsock(sock);
+    if (hp == NULL)
       return -2;
-    }
     my_memcpy((char *) &name.sin_addr, hp->h_addr, hp->h_length);
     name.sin_family = hp->h_addrtype;
   }
@@ -397,10 +393,8 @@
       if (firewall[0])
 	return proxy_connect(sock, server, sport, proxy);
       return sock;		/* async success! */
-    } else {
-      killsock(sock);
+    } else
       return -1;
-    }
   }
   /* synchronous? :/ */
   if (firewall[0])
@@ -411,7 +405,12 @@
 /* ordinary non-binary connection attempt */
 int open_telnet(char *server, int port)
 {
-  return open_telnet_raw(getsock(0), server, port);
+  int sock = getsock(0),
+      ret = open_telnet_raw(sock, server, port);
+
+  if (ret < 0)
+    killsock(sock);
+  return ret;
 }
 
 /* returns a socket number for a listening socket that will accept any
diff -urN eggdrop1.3~/src/tcldcc.c eggdrop1.3/src/tcldcc.c
--- eggdrop1.3~/src/tcldcc.c	Tue Oct  5 11:26:46 1999
+++ eggdrop1.3/src/tcldcc.c	Thu Oct  7 21:10:32 1999
@@ -849,6 +849,7 @@
   sock = getsock(0);
   z = open_telnet_raw(sock, argv[1], atoi(argv[2]));
   if (z < 0) {
+    killsock(sock);
     if (z == (-2))
       strcpy(s, "DNS lookup failed");
     else


More information about the Patches mailing list