player: Drop long-disabled code to resolve IP addresses

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>
This commit is contained in:
Markus Armbruster 2014-01-27 20:28:39 +01:00
parent 199388b084
commit 9ef4f1bf50
5 changed files with 5 additions and 27 deletions

View 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);
}

View 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);
}