From: Julien Ramseier <j.ramseier@gmail.com>
To: musl@lists.openwall.com
Subject: getaddrinfo usage with wrong ip family
Date: Tue, 22 Sep 2015 16:40:30 +0200 [thread overview]
Message-ID: <06898546-AC9C-40F0-A2F5-2F1CC02E185C@gmail.com> (raw)
[-- 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 --]
next reply other threads:[~2015-09-22 14:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 14:40 Julien Ramseier [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=06898546-AC9C-40F0-A2F5-2F1CC02E185C@gmail.com \
--to=j.ramseier@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).