NetBSD Problem Report #52837

From  Sun Dec 17 15:05:36 2017
Return-Path: <>
Received: from ( [])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "", Issuer " CA" (not verified))
	by (Postfix) with ESMTPS id 802267A180
	for <>; Sun, 17 Dec 2017 15:05:36 +0000 (UTC)
Message-Id: <>
Date: Sun, 17 Dec 2017 15:05:35 +0000 (UTC)
Subject: getaddrinfo() resolves "" to
X-Send-Pr-Version: www-1.0

>Number:         52837
>Category:       standards
>Synopsis:       getaddrinfo() resolves "" to
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    standards-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 17 15:10:00 +0000 2017
>Closed-Date:    Sat Oct 06 12:42:03 +0000 2018
>Last-Modified:  Sat Oct 06 12:42:03 +0000 2018
>Originator:     Michael Kaufmann
>Release:        NetBSD-current
NetBSD cubieboard 7.99.71 NetBSD 7.99.71 (CUBIEBOARD) #0: Sat May  6 00:13:25 UTC 2017 evbarm
getaddrinfo() uses inet_aton(), which ignores trailing spaces after numerical IP addresses. This means that getaddrinfo() resolves the hostname "" to the IP address

This bug is also present in some other operating systems, please see
Example program that shows the problem:

#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  struct addrinfo hints, *infoptr, *p;
  char host[256];
  int result;

  memset(&hints, '\0', sizeof(hints));
  hints.ai_family = AF_INET;
  hints.ai_socktype = SOCK_STREAM;

  result = getaddrinfo("", "443", &hints, &infoptr);
  if (result) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(result));

  for(p = infoptr; p != NULL; p = p->ai_next) {
    getnameinfo(p->ai_addr, p->ai_addrlen, host, sizeof(host), NULL, 0, NI_NUMERICHOST);

  return 0;



From: Michael Kaufmann <>
Subject: Re: standards/52837: getaddrinfo() resolves "" to
Date: Thu, 28 Dec 2017 13:30:48 +0100

 This bug has been fixed in FreeBSD, please see

 Maybe NetBSD can use the same bugfix?

From: "Christos Zoulas" <>
Subject: PR/52837 CVS commit: src/lib/libc/net
Date: Thu, 28 Dec 2017 10:12:16 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Thu Dec 28 15:12:16 UTC 2017

 Modified Files:
 	src/lib/libc/net: getaddrinfo.c

 Log Message:
 PR/52837: Michael Kaufmann: getaddrinfo() resolves ""
 to Apply the patch from FreeBSD and explain the rationale.

 To generate a diff of this commit:
 cvs rdiff -u -r1.116 -r1.117 src/lib/libc/net/getaddrinfo.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-When: Mon, 04 Jun 2018 11:35:06 +0000
Is this OK now?
(Do you want it pulled up?)

From: Michael Kaufmann <>
Subject: Re: standards/52837 (getaddrinfo() resolves "" to
Date: Tue, 05 Jun 2018 23:31:03 +0200

 It's OK, thanks!

 A pullup to 8.0 would be nice, but I don't know whether this issue is  
 important enough. Maybe it is, because the FreeBSD developers have  
 applied the patch to their stable branches.

From: Michael Kaufmann <>
Subject: Re: standards/52837
Date: Sat, 06 Oct 2018 13:12:06 +0200

 Please close this PR and stop sending me emails about it!

State-Changed-From-To: feedback->closed
State-Changed-When: Sat, 06 Oct 2018 12:42:03 +0000
Confirmed fixed, thanks for the report!


NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD:,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.