From 82effc97f9f2d1c258ea50cb11b130753b8ba805 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Thu, 1 Jan 2015 16:59:35 -0600 Subject: Switch a lot of strncpy() calls to xstrncpy(). --- toys/pending/dhcpd.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'toys/pending/dhcpd.c') diff --git a/toys/pending/dhcpd.c b/toys/pending/dhcpd.c index 2f0c3a54..9c3389cd 100644 --- a/toys/pending/dhcpd.c +++ b/toys/pending/dhcpd.c @@ -246,8 +246,7 @@ static int get_interface(const char *interface, int *ifindex, uint32_t *oip, uin int fd = xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW); req.ifr_addr.sa_family = AF_INET; - strncpy(req.ifr_name, interface, IFNAMSIZ); - req.ifr_name[IFNAMSIZ-1] = '\0'; + xstrncpy(req.ifr_name, interface, IFNAMSIZ); xioctl(fd, SIOCGIFFLAGS, &req); @@ -625,8 +624,7 @@ static int open_listensock(void) return -1; } memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, gconfig.interface, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ -1] = '\0'; + xstrncpy(ifr.ifr_name, gconfig.interface, IFNAMSIZ); setsockopt(gstate.listensock, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)); memset(&addr, 0, sizeof(addr)); -- cgit v1.2.3