]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-common: Consistently use strlcpy() on interface names
authorMartin Schwenke <martin@meltin.net>
Mon, 1 Aug 2016 05:03:56 +0000 (15:03 +1000)
committerKarolin Seeger <kseeger@samba.org>
Wed, 10 Aug 2016 09:37:23 +0000 (11:37 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit aff33a59479cafcb1f24a07ff76383d47bb196b3)

ctdb/common/system_linux.c

index f871a478e8f45277853ac33a35541055b8c0bf8e..5995cb29c929f650193537a7c20dc6068207acd7 100644 (file)
@@ -108,7 +108,7 @@ int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface)
                }
 
                /* get the mac address */
-               strncpy(if_hwaddr.ifr_name, iface, sizeof(if_hwaddr.ifr_name)-1);
+               strlcpy(if_hwaddr.ifr_name, iface, sizeof(if_hwaddr.ifr_name));
                ret = ioctl(s, SIOCGIFHWADDR, &if_hwaddr);
                if ( ret < 0 ) {
                        close(s);
@@ -202,7 +202,7 @@ int ctdb_sys_send_arp(const ctdb_sock_addr *addr, const char *iface)
                }
 
                /* get the mac address */
-               strncpy(if_hwaddr.ifr_name, iface, sizeof(if_hwaddr.ifr_name)-1);
+               strlcpy(if_hwaddr.ifr_name, iface, sizeof(if_hwaddr.ifr_name));
                ret = ioctl(s, SIOCGIFHWADDR, &if_hwaddr);
                if ( ret < 0 ) {
                        close(s);
@@ -575,7 +575,7 @@ bool ctdb_sys_check_iface_exists(const char *iface)
                return true;
        }
 
-       strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)-1);
+       strlcpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name));
        if (ioctl(s, SIOCGIFINDEX, &ifr) < 0 && errno == ENODEV) {
                DEBUG(DEBUG_CRIT,(__location__ " interface '%s' not found\n", iface));
                close(s);