This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug network/16077] New: Get canonical name from /etc/hosts for AF_INET
- From: "siddhesh at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Wed, 23 Oct 2013 09:30:13 +0000
- Subject: [Bug network/16077] New: Get canonical name from /etc/hosts for AF_INET
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=16077
Bug ID: 16077
Summary: Get canonical name from /etc/hosts for AF_INET
Product: glibc
Version: 2.18
Status: NEW
Severity: normal
Priority: P2
Component: network
Assignee: siddhesh at redhat dot com
Reporter: siddhesh at redhat dot com
Currently, getaddrinfo does not return the actual ai_canonname when an AF_INET
lookup is satisfied from /etc/hosts. Instead, the requested name is simply
copied back.
How Reproducible:
Always
Steps to reproduce:
1. Add the following entry to /etc/hosts
10.10.10.1 foo.test.com foo
2. Build and run the following program:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
int main(int argc, char *argv[])
{
int rc, i;
struct addrinfo hints, *res;
for(i=1; i < argc; i++)
{
memset(&hints,0,sizeof(hints));
memset(&res,0,sizeof(res));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
hints.ai_flags = AI_CANONNAME;
rc = getaddrinfo("foo", NULL, &hints, &res);
if (rc==0 && res && res->ai_canonname)
printf("res->ai_canonname=%s\n",res->ai_canonname);
else
{
printf("res=%p\n", res);
if (res)
printf("res->ai_canonname=%p\n",res->ai_canonname);
}
}
}
Actual Result:
res->ai_canonname=foo
Expected Result:
res->ai_canonname=foo.test.com
--
You are receiving this mail because:
You are on the CC list for the bug.