From 0c0231d9c6edbdae707d4930967108c7eec033b6 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 1 Aug 2016 15:03:56 +1000 Subject: [PATCH] ctdb-common: Consistently use strlcpy() on interface names BUG: https://bugzilla.samba.org/show_bug.cgi?id=12110 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs (cherry picked from commit aff33a59479cafcb1f24a07ff76383d47bb196b3) --- ctdb/common/system_linux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ctdb/common/system_linux.c b/ctdb/common/system_linux.c index 17e89d5f64f..2aa9e35b8f6 100644 --- a/ctdb/common/system_linux.c +++ b/ctdb/common/system_linux.c @@ -115,7 +115,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); @@ -209,7 +209,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); @@ -588,7 +588,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); -- 2.11.4.GIT