This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug network/16077] New: Get canonical name from /etc/hosts for AF_INET


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]