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:
Thomas Haller
2016-03-07 11:11:59 +01:00
parent 1dbe1d70df
commit 0e90f1ba83
7 changed files with 36 additions and 20 deletions

View File

@@ -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)