Fix bogus reporting of interface names, the field returned

in sdl_data is not 0-terminated
This commit is contained in:
Luigi Rizzo 2000-03-21 12:09:23 +00:00
parent 070dac0827
commit cc89db0c68
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=58423

View File

@ -136,10 +136,10 @@ sock_ntop(const struct sockaddr *sa, size_t salen)
case AF_LINK: {
struct sockaddr_dl *sdl = (struct sockaddr_dl *) sa;
if (sdl->sdl_nlen > 0)
snprintf(str, sizeof(str), "%*s",
sdl->sdl_nlen, &sdl->sdl_data[0]);
else
if (sdl->sdl_nlen > 0) {
bcopy(&sdl->sdl_data[0], str, sdl->sdl_nlen);
str[sdl->sdl_nlen]='\0';
} else
snprintf(str, sizeof(str), "link#%d", sdl->sdl_index);
return(str);
}