This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
gethostbyname doesn't check invalid input
- From: Mikulas Patocka <mikulas at artax dot karlin dot mff dot cuni dot cz>
- To: libc-alpha at sourceware dot org
- Date: Wed, 3 Oct 2012 01:07:05 +0200 (CEST)
- Subject: gethostbyname doesn't check invalid input
Hi
I found a weird thing about gethostbyname and getaddrinfo. When the
argument is in the form "1.2.3.4 blablabla" (it contains a valid numeric
ipv4 address, then space and then some garbage), it is correctly resolved
despite the trailing garbage. If it contains a name, space and garbage, it
is rejected ("www.gnu.org blabla" doesn't resolve).
What is even more weird - that Linux/glibc, Solaris, NetBSD and HP-UX all
behave in the same way - they accept a space and a trailing garbage after
numeric ipv4 address.
Is it a bug or is it correct behavior? Is it specified somewhere? Is there
some reason for accepting a space and trailing garbage after numeric
addresses?
Mikulas