diff options
author | brooks <brooks@FreeBSD.org> | 2004-01-31 22:59:03 +0000 |
---|---|---|
committer | brooks <brooks@FreeBSD.org> | 2004-01-31 22:59:03 +0000 |
commit | ee34d661dfd58fb717336382ab24ba06a7cc166f (patch) | |
tree | 4adb288ad6bcdedc841a1ac91af89039a8537dac | |
parent | 2eed8d0864256c7fe182dc8f0df426afa1b0d2e0 (diff) | |
download | FreeBSD-src-ee34d661dfd58fb717336382ab24ba06a7cc166f.zip FreeBSD-src-ee34d661dfd58fb717336382ab24ba06a7cc166f.tar.gz |
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 <PeterJeremy at optushome dot com dot au>
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 0e6ae2b..d8dd71b 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) |