From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26433 invoked by alias); 20 Jan 2014 05:05:46 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 26419 invoked by uid 48); 20 Jan 2014 05:05:42 -0000 From: "nigeltao at golang dot org" To: glibc-bugs@sourceware.org Subject: [Bug network/16469] New: getaddrinfo incorrectly accepts two trailing dots Date: Mon, 20 Jan 2014 05:05:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: network X-Bugzilla-Version: 2.15 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: nigeltao at golang dot org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-01/txt/msg00289.txt.bz2 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 #include #include #include #include #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.