Răsfoiți Sursa

* Removed 'dcc sanity checking'
* Fixed types for port/IP


svn: 929

Bryan Drewery 22 ani în urmă
părinte
comite
11677cee1a
5 a modificat fișierele cu 9 adăugiri și 92 ștergeri
  1. 1 1
      doc/UPDATES
  2. 2 10
      src/mod/server.mod/server.c
  3. 0 76
      src/net.c
  4. 0 2
      src/net.h
  5. 6 3
      src/types.h

+ 1 - 1
doc/UPDATES

@@ -3,7 +3,7 @@ This is a summary of ChangeLog basically.
 1.1.6
 
 1.Fixed a cosmetic error in cmd_downbots.
-2.Cleaned up and removed more un-needed code.
+2.Cleaned up and removed a ton of un-needed and old code.
 3.Fixed a bug in defalg_user()
 4.Several user cmds on BOTS were not being shared.
 5.Fixed a fatal bug in +take.

+ 2 - 10
src/mod/server.mod/server.c

@@ -1251,8 +1251,6 @@ static int ctcp_DCC_CHAT(char *nick, char *from, struct userrec *u, char *object
       dprintf(DP_HELP, "NOTICE %s :%s (invalid port)\n", nick, DCC_CONNECTFAILED1);
     putlog(LOG_MISC, "*", "%s: CHAT (%s!%s)", DCC_CONNECTFAILED3, nick, from);
   } else {
-    if (!sanitycheck_dcc(nick, from, ip, prt))
-      return BIND_RET_BREAK;
     i = new_dcc(&DCC_DNSWAIT, sizeof(struct dns_info));
     if (i < 0) {
       putlog(LOG_MISC, "*", "DCC connection: CHAT (%s!%s)", dcc[i].nick, ip);
@@ -1298,15 +1296,9 @@ static void dcc_chat_hostresolved(int i)
   struct flag_record fr = {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0};
 
   egg_snprintf(buf, sizeof buf, "%d", dcc[i].port);
-#ifndef USE_IPV6
-  if (!hostsanitycheck_dcc(dcc[i].nick, dcc[i].host, dcc[i].addr, dcc[i].u.dns->host, buf)) {
-    lostdcc(i);
-    return;
-  }
-#else
+#ifdef USE_IPV6
   if (sockprotocol(dcc[i].sock) == AF_INET6) {
-    strcpy(ip,dcc[i].addr6); /* safe, addr6 is 121 */
-    debug0("afinet6, af_type, strcpy");
+    strcpy(ip, dcc[i].addr6); /* safe, addr6 is 121 */
   } else
 #endif /* !USE_IPV6 */
   egg_snprintf(ip, sizeof ip, "%lu", iptolong(htonl(dcc[i].addr)));

+ 0 - 76
src/net.c

@@ -54,9 +54,6 @@ sock_list *socklist = NULL;	/* Enough to be safe			    */
 int	MAXSOCKS = 0;
 jmp_buf	alarmret;		/* Env buffer for alarm() returns	    */
 
-static int	dcc_sanitycheck = 0;	/* We should do some sanity checking on dcc connections. */
-
-
 /* Types of proxy */
 #define PROXY_SOCKS   1
 #define PROXY_SUN     2
@@ -1749,79 +1746,6 @@ void tell_netdebug(int idx)
   dprintf(idx, " done.\n");
 }
 
-/* Security-flavoured sanity checking on DCC connections of all sorts can be
- * done with this routine.  Feed it the proper information from your DCC
- * before you attempt the connection, and this will make an attempt at
- * figuring out if the connection is really that person, or someone screwing
- * around.  It's not foolproof, but anything that fails this check probably
- * isn't going to work anyway due to masquerading firewalls, NAT routers, 
- * or bugs in mIRC.
- */
-int sanitycheck_dcc(char *nick, char *from, char *ipaddy, char *port)
-{
-  /* According to the latest RFC, the clients SHOULD be able to handle
-   * DNS names that are up to 255 characters long.  This is not broken.
-   */
-
-  /* This function needs to be updated for IPv6 IP's, although it doesn't
-   * currently harm them (afaik)
-   */
-
-  char badaddress[16] = "";
-  IP ip = my_atoul(ipaddy);
-  port_t prt = (port_t) atoi(port);
-
-  /* It is disabled HERE so we only have to check in *one* spot! */
-  if (!dcc_sanitycheck)
-    return 1;
-
-  if (prt < 1) {
-    putlog(LOG_MISC, "*", "ALERT: (%s!%s) specified an impossible port of %u!",
-	   nick, from, prt);
-    return 0;
-  }
-  sprintf(badaddress, "%lu.%lu.%lu.%lu", (ip >> 24) & 0xff, (ip >> 16) & 0xff,
-	  (ip >> 8) & 0xff, ip & 0xff);
-  if (ip < (1 << 24)) {
-    putlog(LOG_MISC, "*", "ALERT: (%s!%s) specified an impossible IP of %s!",
-	   nick, from, badaddress);
-    return 0;
-  }
-  return 1;
-}
-
-int hostsanitycheck_dcc(char *nick, char *from, IP ip, char *dnsname,
-		        char *prt)
-{
-  /* According to the latest RFC, the clients SHOULD be able to handle
-   * DNS names that are up to 255 characters long.  This is not broken.
-   */
-  char hostn[256] = "", badaddress[16] = "";
-
-  /* It is disabled HERE so we only have to check in *one* spot! */
-  if (!dcc_sanitycheck)
-    return 1;
-  sprintf(badaddress, "%lu.%lu.%lu.%lu", (ip >> 24) & 0xff, (ip >> 16) & 0xff,
-	  (ip >> 8) & 0xff, ip & 0xff);
-  /* These should pad like crazy with zeros, since 120 bytes or so is
-   * where the routines providing our data currently lose interest. I'm
-   * using the n-variant in case someone changes that...
-   */
-  strncpyz(hostn, extracthostname(from), sizeof hostn);
-  if (!egg_strcasecmp(hostn, dnsname)) {
-    putlog(LOG_DEBUG, "*", "DNS information for submitted IP checks out.");
-    return 1;
-  }
-  if (!strcmp(badaddress, dnsname))
-    putlog(LOG_MISC, "*", "ALERT: (%s!%s) sent a DCC request with bogus IP "
-	   "information of %s port %s. %s does not resolve to %s!", nick, from,
-	    badaddress, prt, from, badaddress);
-  else
-    return 1; /* <- usually happens when we have 
-		    a user with an unresolved hostmask! */
-  return 0;
-}
-
 /* Checks wether the referenced socket has data queued.
  *
  * Returns true if the incoming/outgoing (depending on 'type') queues

+ 0 - 2
src/net.h

@@ -162,8 +162,6 @@ void tputs(int, char *, size_t);
 void dequeue_sockets();
 int sockgets(char *, int *);
 void tell_netdebug(int);
-int sanitycheck_dcc(char *, char *, char *, char *);
-int hostsanitycheck_dcc(char *, char *, IP, char *, char *);
 char *iptostr(IP);
 int sock_has_data(int, int);
 int sockoptions(int sock, int operation, int sock_options);

+ 6 - 3
src/types.h

@@ -5,6 +5,9 @@
 #  include "config.h"
 #endif
 
+#include <sys/types.h>
+#include <netinet/in.h>
+
 /* For local console: */
 #define STDIN      0
 #define STDOUT     1
@@ -32,10 +35,10 @@ typedef unsigned short int      u_16bit_t;
 typedef unsigned char           u_8bit_t;
 
 /* IP type */
-typedef unsigned long		IP;
-typedef u_32bit_t 		dword;
+typedef in_addr_t		IP;
+typedef u_int32_t 		dword;
 
 /* port */
-typedef unsigned short		port_t;
+typedef in_port_t		port_t;
 
 #endif /* !_TYPES_H */