From: Rich Felker <dalias@libc.org>
To: Marco Dickert <marco@misterunknown.de>
Cc: musl@lists.openwall.com
Subject: Re: Bug in getaddrinfo
Date: Thu, 21 Jun 2018 22:26:40 -0400 [thread overview]
Message-ID: <20180622022640.GR1392@brightrain.aerifal.cx> (raw)
In-Reply-To: <20180621220431.aylvgwax6h766y5r@kronos.misterunknown.de>
[-- Attachment #1: Type: text/plain, Size: 1429 bytes --]
On Fri, Jun 22, 2018 at 12:04:31AM +0200, Marco Dickert wrote:
> Hi all.
>
> I found a bug in the musl implementation of getaddrinfo(). It apparently returns
> a bad ai_canonname value. I used this [1] code to produce the following results
^^^
Please attach testcases rather than linking to transient pastebins.
I've saved and attached the linked code here.
> on an alpine linux (edge):
>
> ----
> alpine:~# ./addrinfo-test mail.misterunknown.de
> Result 0 0xda051c83080
> Canonname mail.misterunknown.de
> alpine:~# ./addrinfo-test mail.misterunknown.de.
> Result 0 0x53f7dac4080
> Canonname mail.misterunknown.de.
> ----
>
> The problem is the trailing dot in the Commonname in the second example, which
> should not be there. See also this [2] bug report I opened in the first place.
Per POSIX,
if the canonical name is not available, then ai_canonname shall
refer to the nodename argument or a string with the same contents.
It's not entirely clear what "available" means, but I think it's
generally interpreted as meaning "the requested name is a CNAME".
On the other hand we already define availability for another case,
search domains, where a duplicate of the requested nodename argument
is not returned, so I think it's reasonable to make a change here too,
especially if that's what other implementations do. I'll take a look
at it.
Thanks for the report.
Rich
[-- Attachment #2: addrinfo-test.c --]
[-- Type: text/plain, Size: 592 bytes --]
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char** argv) {
struct addrinfo hints, *ai;
int result;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
result = getaddrinfo(argv[1], NULL, &hints, &ai);
printf("Result %d %p\n", result, ai);
if (result == 0 && ai != NULL) {
printf("Canonname %s\n", ai->ai_canonname);
}
}
next prev parent reply other threads:[~2018-06-22 2:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-21 22:04 Marco Dickert
2018-06-22 2:26 ` Rich Felker [this message]
2018-06-26 9:36 ` Marco Dickert
2018-06-26 20:40 ` 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=20180622022640.GR1392@brightrain.aerifal.cx \
--to=dalias@libc.org \
--cc=marco@misterunknown.de \
--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).