diff options
author | 2004-01-21 00:30:15 +0000 | |
---|---|---|
committer | 2004-01-21 00:30:15 +0000 | |
commit | f9ba639dcc110a89bde074d6d1e693e4d1fa1fd8 (patch) | |
tree | 9639fa4d6836fc4f431dab2d934408ef730080d7 /lib/libpcap/inet.c | |
parent | Check the values given to -h and -s. Closes PR 3640. (diff) | |
download | wireguard-openbsd-f9ba639dcc110a89bde074d6d1e693e4d1fa1fd8.tar.xz wireguard-openbsd-f9ba639dcc110a89bde074d6d1e693e4d1fa1fd8.zip |
Replace some strncpy() calls with strlcpy()
tested by jose@, ok canacar@ and otto@
Diffstat (limited to 'lib/libpcap/inet.c')
-rw-r--r-- | lib/libpcap/inet.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/libpcap/inet.c b/lib/libpcap/inet.c index b71df9dad91..8d9f93c8dad 100644 --- a/lib/libpcap/inet.c +++ b/lib/libpcap/inet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: inet.c,v 1.14 2002/02/19 19:39:37 millert Exp $ */ +/* $OpenBSD: inet.c,v 1.15 2004/01/21 00:30:15 jfb Exp $ */ /* * Copyright (c) 1994, 1995, 1996, 1997, 1998 @@ -35,7 +35,7 @@ #ifndef lint static const char rcsid[] = - "@(#) $Header: /home/cvs/src/lib/libpcap/inet.c,v 1.14 2002/02/19 19:39:37 millert Exp $ (LBL)"; + "@(#) $Header: /home/cvs/src/lib/libpcap/inet.c,v 1.15 2004/01/21 00:30:15 jfb Exp $ (LBL)"; #endif #include <sys/param.h> @@ -123,14 +123,13 @@ pcap_lookupdev(errbuf) } } if (mp == NULL) { - (void)strncpy(errbuf, "no suitable device found", + (void)strlcpy(errbuf, "no suitable device found", PCAP_ERRBUF_SIZE); freeifaddrs(ifap); return (NULL); } - (void)strncpy(device, mp->ifa_name, sizeof(device) - 1); - device[sizeof(device) - 1] = '\0'; + (void)strlcpy(device, mp->ifa_name, sizeof(device)); freeifaddrs(ifap); return (device); #else @@ -181,7 +180,8 @@ pcap_lookupdev(errbuf) * SIOCGIFFLAGS stomps over it because the requests * are returned in a union.) */ - strncpy(ifr.ifr_name, ifrp->ifr_name, sizeof(ifr.ifr_name)); + (void)strlcpy(ifr.ifr_name, ifrp->ifr_name, + sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFFLAGS, (char *)&ifr) < 0) { if (errno == ENXIO) continue; @@ -212,8 +212,7 @@ pcap_lookupdev(errbuf) return (NULL); } - (void)strncpy(device, mp->ifr_name, sizeof(device) - 1); - device[sizeof(device) - 1] = '\0'; + (void)strlcpy(device, mp->ifr_name, sizeof(device)); return (device); #endif } @@ -239,7 +238,7 @@ pcap_lookupnet(device, netp, maskp, errbuf) /* XXX Work around Linux kernel bug */ ifr.ifr_addr.sa_family = AF_INET; #endif - (void)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); + (void)strlcpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) { if (errno == EADDRNOTAVAIL) { (void)snprintf(errbuf, PCAP_ERRBUF_SIZE, |