public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "siddhesh at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug network/16077] New: Get canonical name from /etc/hosts for AF_INET
Date: Wed, 23 Oct 2013 09:30:00 -0000	[thread overview]
Message-ID: <bug-16077-131@http.sourceware.org/bugzilla/> (raw)

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.


             reply	other threads:[~2013-10-23  9:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-23  9:30 siddhesh at redhat dot com [this message]
2013-10-23 14:23 ` [Bug network/16077] " siddhesh at redhat dot com
2013-11-28 11:53 ` siddhesh at redhat dot com
2014-06-13 12:31 ` fweimer at redhat dot com

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=bug-16077-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /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.
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 read-only IMAP folder(s) and NNTP newsgroup(s).