]> git.pond.sub.org Git - empserver/commitdiff
player: Drop long-disabled code to resolve IP addresses
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 27 Jan 2014 19:28:39 +0000 (20:28 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 1 Feb 2015 15:52:59 +0000 (16:52 +0100)
Disabled since commit 32fac04 (v4.2.13) because it could at the time
use more stack space than we provided.  Additional issues: code still
uses obsolete gethostbyaddr() rather than getnameinfo(), and we
provide only 512 bytes for host names instead of the customary
NI_MAXHOST (1025) bytes.

All three issues would be easy enough to fix.  What's not so easy is
to avoid blocking on the synchronous DNS lookup.  Without that,
connecting repeatedly from a range of addresses with slow reverse
lookup could conceivably be employed as a denial of service attack.

We've been living without reverse lookup for close to ten years.  Bury
the corpse, and move on.

Bonus: sizeof(struct natstr) is cut in half.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
include/misc.h
include/nat.h
include/player.h
src/lib/player/accept.c
src/lib/player/player.c

index 72925327a51ec87dbea1635e476f5589f5d2fdec..06157f16a19fd5c1cfb9bb55d01f8fcdbb011f15 100644 (file)
@@ -29,7 +29,7 @@
  *
  *  Known contributors to this file:
  *     Doug Hay, 1998
- *     Markus Armbruster, 2004-2013
+ *     Markus Armbruster, 2004-2014
  */
 
 #ifndef MISC_H
 #define ATTRIBUTE(attrs)
 #endif
 
-/*
- * This uses a lot of thread stack with some versions of GNU libc,
- * which can lead to nasty heap smashes (observed with 2.2.93).
- * Disabled for now, until we readjust thread stack sizes.
- */
-#if 0
-#define RESOLVE_IPADDRESS      /* resolve ip addresses into hostnames */
-#endif
-
 #ifndef bit
 #define bit(x)         (1<<(x))
 #endif
index 15c4ecd95fccd9c5cc80a948b2f46fef7613426a..6c83faaf77afc7266012b65b7086b466a7506b94 100644 (file)
@@ -31,7 +31,7 @@
  *     Ken Stevens, 1995
  *     Steve McClure, 1998-2000
  *     Ron Koenderink, 2005-2008
- *     Markus Armbruster, 2005-2013
+ *     Markus Armbruster, 2005-2014
  */
 
 #ifndef NAT_H
@@ -95,7 +95,6 @@ struct natstr {
     char nat_cnam[20];         /* country name */
     char nat_pnam[20];         /* representative */
     char nat_hostaddr[46];     /* host addr of last user */
-    char nat_hostname[512];    /* hostname of last user, may be empty */
     char nat_userid[32];       /* userid of last user, may be empty */
     coord nat_xcap, nat_ycap;  /* cap location in abs coords */
     coord nat_xorg, nat_yorg;  /* origin location in abs coords */
index ddd26d6de51cedd9fdb2ede4e89bca96cf132c84..7ddfbdcb3577bc3d26cf5dc467747d202c774e19 100644 (file)
@@ -59,7 +59,6 @@ struct player {
     struct emp_qelem queue;
     empth_t *proc;
     char hostaddr[46];
-    char hostname[512];                /* may be empty */
     char client[128];          /* may be empty */
     char userid[32];           /* may be empty */
     int authenticated;
index 52982a9955b55e9e617e5aa45f714a092ddae27d..faebf8e5340700fc9f773a9367161c52addb7cda 100644 (file)
@@ -28,7 +28,7 @@
  *
  *  Known contributors to this file:
  *     Dave Pare, 1994
- *     Markus Armbruster, 2005-2013
+ *     Markus Armbruster, 2005-2014
  */
 
 #include <config.h>
@@ -174,9 +174,6 @@ player_accept(void *unused)
     int ns;
     int set = 1;
     char buf[128];
-#ifdef RESOLVE_IPADDRESS
-    struct hostent *hostp;
-#endif
 
     /* auto sockaddr_storage would be simpler, but less portable */
     sap = malloc(player_addrlen);
@@ -212,11 +209,6 @@ player_accept(void *unused)
            continue;
        }
        logerror("Connect from %s", np->hostaddr);
-#ifdef RESOLVE_IPADDRESS
-       hostp = gethostbyaddr(inaddr, player_addrlen, sap->sa_family);
-       if (NULL != hostp)
-           strcpy(np->hostname, hostp->h_name);
-#endif /* RESOLVE_IPADDRESS */
        sprintf(buf, "Conn%d", conn_cnt++);
        empth_create(player_login, 1024 * 1024, 0, buf, np);
     }
index 6181a2e42dc19e4c9e4b79acf68fee169e1d7eb7..96d3b73254d7f6fb4c8945b79c06a982f4b32881 100644 (file)
@@ -80,11 +80,9 @@ player_main(struct player *p)
           natp->nat_last_login <= natp->nat_last_logout
           ? ctime(&natp->nat_last_logout) : "?");
        pr("                  by: %s@%s\n",
-          natp->nat_userid,
-          *natp->nat_hostname ? natp->nat_hostname : natp->nat_hostaddr);
+          natp->nat_userid, natp->nat_hostaddr);
     }
     strcpy(natp->nat_userid, player->userid);
-    strcpy(natp->nat_hostname, player->hostname);
     strcpy(natp->nat_hostaddr, player->hostaddr);
     natp->nat_last_login = player->curup;
     putnat(natp);
@@ -289,6 +287,5 @@ quit(void)
 char *
 praddr(struct player *p)
 {
-    return prbuf("%s@%s", p->userid,
-                *p->hostname ? p->hostname : p->hostaddr);
+    return prbuf("%s@%s", p->userid, p->hostaddr);
 }