mailing list of musl libc
 help / color / mirror / code / Atom feed
* getaddrinfo usage with wrong ip family
@ 2015-09-22 14:40 Julien Ramseier
  2015-09-22 15:16 ` Rich Felker
  0 siblings, 1 reply; 7+ messages in thread
From: Julien Ramseier @ 2015-09-22 14:40 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 835 bytes --]

Hello,

I discovered a potential problem in getaddrinfo/__lookup_name.
When calling getaddrinfo  with an IP string not matching the specified family,
name_from_numeric() in __lookup_name() will not recognize it and the 
external dns resolver will be used.

So the following code:

const struct addrinfo hints = {
    .ai_flags = AI_ADDRCONFIG,
    .ai_family = AF_INET,
    .ai_socktype = SOCK_STREAM,
};

getaddrinfo("::1", NULL, &hints, &result);

will actually succeed instead of returning EAI_NONAME,
and perform a "A ::1" query.
Some misbehaving dns servers will then answer with 0.0.0.1.

I don’t know if this behavior is desirable. If not, I’m still not sure
where this should be fixed. Maybe should we prevent sending
A and AAAA dns queries with IP as hostname in __res_mkquery() ?

—
Julien


[-- Attachment #2: Type: text/html, Size: 2002 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-09-25  1:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-22 14:40 getaddrinfo usage with wrong ip family Julien Ramseier
2015-09-22 15:16 ` Rich Felker
2015-09-24 10:27   ` Julien Ramseier
2015-09-24 10:59     ` Szabolcs Nagy
2015-09-24 15:11       ` Julien Ramseier
2015-09-24 15:39         ` Rich Felker
2015-09-25  1:48           ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).