This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug network/16469] New: getaddrinfo incorrectly accepts two trailing dots
- From: "nigeltao at golang dot org" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Mon, 20 Jan 2014 05:05:40 +0000
- Subject: [Bug network/16469] New: getaddrinfo incorrectly accepts two trailing dots
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=16469
Bug ID: 16469
Summary: getaddrinfo incorrectly accepts two trailing dots
Product: glibc
Version: 2.15
Status: NEW
Severity: normal
Priority: P2
Component: network
Assignee: unassigned at sourceware dot org
Reporter: nigeltao at golang dot org
getaddrinfo("www.google.com..", etc) with two trailing dots resolves, but I
expected an error, as "www.google.com.." is not a valid domain name.
"www.google.com." with one trailing dot works as expected, as one trailing dot
means a FQDN. "www.google.com..." with three trailing dots gives a "No address
associated with hostname" error, as expected.
Ubuntu 12.04 "Precise", so glibc 2.15.
--------
/* This example program adapted from
http://en.wikipedia.org/wiki/Getaddrinfo#Example */
/* Note the two trailing dots in the "www.google.com.." hostname! */
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#ifndef NI_MAXHOST
#define NI_MAXHOST 1025
#endif
int main(void)
{
struct addrinfo *result;
struct addrinfo *res;
int error;
error = getaddrinfo("www.google.com..", NULL, NULL, &result);
if (error != 0)
{
if (error == EAI_SYSTEM)
{
perror("getaddrinfo");
}
else
{
fprintf(stderr, "error in getaddrinfo: %s\n", gai_strerror(error));
}
exit(EXIT_FAILURE);
}
for (res = result; res != NULL; res = res->ai_next)
{
char hostname[NI_MAXHOST] = "";
error = getnameinfo(res->ai_addr, res->ai_addrlen, hostname,
NI_MAXHOST, NULL, 0, 0);
if (error != 0)
{
fprintf(stderr, "error in getnameinfo: %s\n", gai_strerror(error));
continue;
}
if (*hostname != '\0')
printf("hostname: %s\n", hostname);
}
freeaddrinfo(result);
return 0;
}
--------
--
You are receiving this mail because:
You are on the CC list for the bug.