mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-16 15:11:52 +00:00
Fix bogus reporting of interface names, the field returned
in sdl_data is not 0-terminated
This commit is contained in:
parent
070dac0827
commit
cc89db0c68
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=58423
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user