From bbe513dbf8ad3e0a428563c3c3d36c71622ab242 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Sat, 31 Jan 2004 22:59:03 +0000 Subject: [PATCH] Use memcpy plus a manual NUL termination when copying the interface name from the sdl because strlcpy requires that the source string be NUL-terminated unlike strncpy. Submitted by: Peter Jeremy --- sbin/ifconfig/ifconfig.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 0e6ae2b8c52b..d8dd71bf7b63 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -596,9 +596,11 @@ main(int argc, char *argv[]) addrcount++; next += nextifm->ifm_msglen; } - strlcpy(name, sdl->sdl_data, - sizeof(name) <= sdl->sdl_nlen ? - sizeof(name) : sdl->sdl_nlen + 1); + memcpy(name, sdl->sdl_data, + sizeof(name) < sdl->sdl_nlen ? + sizeof(name)-1 : sdl->sdl_nlen); + name[sizeof(name) < sdl->sdl_nlen ? + sizeof(name)-1 : sdl->sdl_nlen] = '\0'; if (all || namesonly) { if (uponly)