summaryrefslogtreecommitdiff
path: root/usr.sbin/pppd/sys-bsd.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pppd/sys-bsd.c')
-rw-r--r--usr.sbin/pppd/sys-bsd.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/usr.sbin/pppd/sys-bsd.c b/usr.sbin/pppd/sys-bsd.c
index 4d5aac3f7c1..84450cbfced 100644
--- a/usr.sbin/pppd/sys-bsd.c
+++ b/usr.sbin/pppd/sys-bsd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys-bsd.c,v 1.14 1998/05/08 04:52:33 millert Exp $ */
+/* $OpenBSD: sys-bsd.c,v 1.15 2001/06/23 15:34:02 lebel Exp $ */
/*
* sys-bsd.c - System-dependent procedures for setting up
@@ -26,7 +26,7 @@
#if 0
static char rcsid[] = "Id: sys-bsd.c,v 1.31 1998/04/02 12:04:19 paulus Exp $";
#else
-static char rcsid[] = "$OpenBSD: sys-bsd.c,v 1.14 1998/05/08 04:52:33 millert Exp $";
+static char rcsid[] = "$OpenBSD: sys-bsd.c,v 1.15 2001/06/23 15:34:02 lebel Exp $";
#endif
#endif
@@ -139,8 +139,7 @@ sys_cleanup()
struct ifreq ifr;
if (if_is_up) {
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
- ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
+ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) >= 0
&& ((ifr.ifr_flags & IFF_UP) != 0)) {
ifr.ifr_flags &= ~IFF_UP;
@@ -190,8 +189,7 @@ ppp_available()
if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
return 1; /* can't tell */
- strncpy(ifr.ifr_name, "ppp0", sizeof(ifr.ifr_name) - 1);
- ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
+ strlcpy(ifr.ifr_name, "ppp0", sizeof(ifr.ifr_name));
ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0;
close(s);
@@ -342,8 +340,7 @@ sipxfaddr(unit, network, node)
result = 0;
} else {
bzero (&ifr, sizeof(ifr));
- strncpy (ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
- ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
+ strlcpy (ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
sipx->sipx_len = sizeof(*sipx);
sipx->sipx_family = AF_IPX;
@@ -393,8 +390,7 @@ cipxfaddr(unit)
result = 0;
} else {
bzero (&ifr, sizeof(ifr));
- strncpy (ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
- ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
+ strlcpy (ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
sipx->sipx_len = sizeof(*sipx);
sipx->sipx_family = AF_IPX;
@@ -796,8 +792,7 @@ ppp_send_config(unit, mtu, asyncmap, pcomp, accomp)
u_int x;
struct ifreq ifr;
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
- ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
+ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
ifr.ifr_mtu = mtu;
if (ioctl(sockfd, SIOCSIFMTU, (caddr_t) &ifr) < 0) {
syslog(LOG_ERR, "ioctl(SIOCSIFMTU): %m");
@@ -997,8 +992,7 @@ sifup(u)
{
struct ifreq ifr;
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
- ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
+ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
syslog(LOG_ERR, "ioctl (SIOCGIFFLAGS): %m");
return 0;
@@ -1049,8 +1043,7 @@ sifdown(u)
ioctl(ppp_fd, PPPIOCSNPMODE, (caddr_t) &npi);
/* ignore errors, because ppp_fd might have been closed by now. */
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
- ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
+ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) {
syslog(LOG_ERR, "ioctl (SIOCGIFFLAGS): %m");
rv = 0;
@@ -1085,8 +1078,7 @@ sifaddr(u, o, h, m)
struct ifaliasreq ifra;
struct ifreq ifr;
- strncpy(ifra.ifra_name, ifname, sizeof(ifra.ifra_name) - 1);
- ifra.ifra_name[sizeof(ifra.ifra_name) - 1] = '\0';
+ strlcpy(ifra.ifra_name, ifname, sizeof(ifra.ifra_name));
SET_SA_FAMILY(ifra.ifra_addr, AF_INET);
((struct sockaddr_in *) &ifra.ifra_addr)->sin_addr.s_addr = o;
SET_SA_FAMILY(ifra.ifra_broadaddr, AF_INET);
@@ -1097,8 +1089,7 @@ sifaddr(u, o, h, m)
} else
BZERO(&ifra.ifra_mask, sizeof(ifra.ifra_mask));
BZERO(&ifr, sizeof(ifr));
- strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1);
- ifr.ifr_name[sizeof(ifr.ifr_name) - 1] = '\0';
+ strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (ioctl(sockfd, SIOCDIFADDR, (caddr_t) &ifr) < 0) {
if (errno != EADDRNOTAVAIL)
syslog(LOG_WARNING, "Couldn't remove interface address: %m");
@@ -1129,8 +1120,7 @@ cifaddr(u, o, h)
struct ifaliasreq ifra;
ifaddrs[0] = 0;
- strncpy(ifra.ifra_name, ifname, sizeof(ifra.ifra_name) - 1);
- ifra.ifra_name[sizeof(ifra.ifra_name) - 1] = '\0';
+ strlcpy(ifra.ifra_name, ifname, sizeof(ifra.ifra_name));
SET_SA_FAMILY(ifra.ifra_addr, AF_INET);
((struct sockaddr_in *) &ifra.ifra_addr)->sin_addr.s_addr = o;
SET_SA_FAMILY(ifra.ifra_broadaddr, AF_INET);
@@ -1408,8 +1398,7 @@ get_ether_addr(ipaddr, hwaddr)
((char *)&ifr->ifr_addr + ifr->ifr_addr.sa_len)) {
if (ifr->ifr_addr.sa_family == AF_INET) {
ina = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr;
- strncpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name) - 1);
- ifreq.ifr_name[sizeof(ifreq.ifr_name) - 1] = '\0';
+ strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
/*
* Check that the interface is up, and not point-to-point
* or loopback.
@@ -1509,8 +1498,7 @@ GetMask(addr)
/*
* Check that the interface is up, and not point-to-point or loopback.
*/
- strncpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name) - 1);
- ifreq.ifr_name[sizeof(ifreq.ifr_name) - 1] = '\0';
+ strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name));
if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0)
continue;
if ((ifreq.ifr_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK))