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

@ -29,7 +29,7 @@
*
* Known contributors to this file:
* Doug Hay, 1998
* Markus Armbruster, 2004-2013
* Markus Armbruster, 2004-2014
*/
#ifndef MISC_H
@ -51,15 +51,6 @@
#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

View 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 */

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