svn commit: r287349 - head/lib/libc/net
Hiroki Sato
hrs at FreeBSD.org
Tue Sep 1 08:29:40 UTC 2015
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;
More information about the svn-src-all
mailing list