diff options
author | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-01-21 00:30:16 +0000 |
---|---|---|
committer | Jean-Francois Brousseau <jfb@cvs.openbsd.org> | 2004-01-21 00:30:16 +0000 |
commit | 749724bd744d27e0c7bb851226133f1509be6584 (patch) | |
tree | 0fcca6d3822cd8f2645230924f374b9ede16aeab /lib/libpcap/inet.c | |
parent | 47dd934cb84b71e78e79df9251cfc2ab126aaf22 (diff) |
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 2d932ceb930..63940e1a53d 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: /cvs/OpenBSD/src/lib/libpcap/inet.c,v 1.14 2002/02/19 19:39:37 millert Exp $ (LBL)"; + "@(#) $Header: /cvs/OpenBSD/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, |