From owner-svn-src-all@freebsd.org Tue Sep 1 08:29:39 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E6FBC9C7F23; Tue, 1 Sep 2015 08:29:39 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D8371AD8; Tue, 1 Sep 2015 08:29:39 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t818TdYR085189; Tue, 1 Sep 2015 08:29:39 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t818TdkY085188; Tue, 1 Sep 2015 08:29:39 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201509010829.t818TdkY085188@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Tue, 1 Sep 2015 08:29:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287349 - head/lib/libc/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 08:29:40 -0000 Author: hrs Date: Tue Sep 1 08:29:39 2015 New Revision: 287349 URL: https://svnweb.freebsd.org/changeset/base/287349 Log: Print sdl->sdl_data when sdl->sdl_nlen > 0 as link_ntoa(3) does. MFC after: 1 week Modified: head/lib/libc/net/getnameinfo.c Modified: head/lib/libc/net/getnameinfo.c ============================================================================== --- head/lib/libc/net/getnameinfo.c Tue Sep 1 07:33:36 2015 (r287348) +++ head/lib/libc/net/getnameinfo.c Tue Sep 1 08:29:39 2015 (r287349) @@ -396,9 +396,24 @@ getnameinfo_link(const struct sockaddr * n = snprintf(host, hostlen, "link#%d", sdl->sdl_index); if (n > hostlen) { *host = '\0'; - return EAI_MEMORY; + return (EAI_MEMORY); } - return 0; + return (0); + } + + if (sdl->sdl_nlen > 0) { + if (sdl->sdl_nlen + 1 > hostlen) { + *host = '\0'; + return (EAI_MEMORY); + } + memcpy(host, sdl->sdl_data, sdl->sdl_nlen); + n = sdl->sdl_nlen; + host += n; + if (sdl->sdl_alen > 0) { + *host++ = ':'; + n++; + } + hostlen -= n; } switch (sdl->sdl_type) { @@ -440,10 +455,7 @@ getnameinfo_link(const struct sockaddr * } static int -hexname(cp, len, host, hostlen) - const u_int8_t *cp; - char *host; - size_t len, hostlen; +hexname(const u_int8_t *cp, size_t len, char *host, size_t hostlen) { int i, n; char *outp = host;