Date: Tue, 1 Sep 2015 08:29:39 +0000 (UTC) From: Hiroki Sato <hrs@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287349 - head/lib/libc/net Message-ID: <201509010829.t818TdkY085188@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509010829.t818TdkY085188>