platform: add and use nm_utils_ifname_cpy() helper
Coverity complains rightly about "strncpy (dst, ifname, IFNAMSIZ)" because it might leave @dst non-NULL-terminated, in case @ifname is too long (which already would be a bug in the first place). Replace the strcpy() uses by a new helper nm_utils_ifname_cpy() that asserts against valid arguments.
This commit is contained in:
@@ -4835,7 +4835,7 @@ tun_add (NMPlatform *platform, const char *name, gboolean tap,
|
||||
if (fd < 0)
|
||||
return FALSE;
|
||||
|
||||
strncpy (ifr.ifr_name, name, IFNAMSIZ);
|
||||
nm_utils_ifname_cpy (ifr.ifr_name, name);
|
||||
ifr.ifr_flags = tap ? IFF_TAP : IFF_TUN;
|
||||
|
||||
if (!pi)
|
||||
|
Reference in New Issue
Block a user