X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fsys-ultrix.c;h=92d3bd26d771b4351038699ac19cdb6154ee05be;hp=cb1303bad47fa5c015e13ca245c8c57b5b0178c7;hb=1fae28ce79350b03f0cf8a69ad06dd68637cd6b1;hpb=0c752a555e174a838a30b7e8632fbffc58ba00a6 diff --git a/pppd/sys-ultrix.c b/pppd/sys-ultrix.c index cb1303b..92d3bd2 100644 --- a/pppd/sys-ultrix.c +++ b/pppd/sys-ultrix.c @@ -21,7 +21,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: sys-ultrix.c,v 1.24 1999/03/08 01:46:24 paulus Exp $"; +static char rcsid[] = "$Id: sys-ultrix.c,v 1.25 1999/03/12 06:07:24 paulus Exp $"; #endif /* @@ -106,7 +106,7 @@ sys_cleanup() struct ifreq ifr; if (if_is_up) { - strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); + strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) >= 0 && ((ifr.ifr_flags & IFF_UP) != 0)) { ifr.ifr_flags &= ~IFF_UP; @@ -186,7 +186,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)); + strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), "ppp0"); ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; close(s); @@ -840,7 +840,7 @@ sifup(u) { struct ifreq ifr; - strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); + strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { syslog(LOG_ERR, "ioctl (SIOCGIFFLAGS): %m"); return 0; @@ -891,7 +891,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)); + strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { syslog(LOG_ERR, "ioctl (SIOCGIFFLAGS): %m"); rv = 0; @@ -926,7 +926,7 @@ sifaddr(u, o, h, m) struct ifreq ifr; ret = 1; - strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); + strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); SET_SA_FAMILY(ifr.ifr_addr, AF_INET); if (m != 0) { ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = m; @@ -1108,7 +1108,7 @@ get_ether_addr(ipaddr, hwaddr) ((char *)&ifr->ifr_addr + sizeof(struct sockaddr))) { 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)); + strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); /* * Check that the interface is up, and not point-to-point * or loopback. @@ -1139,7 +1139,7 @@ get_ether_addr(ipaddr, hwaddr) /* * Grab the physical address for this interface. */ - strncpy(ifdevea.ifr_name, ifr->ifr_name, sizeof(ifdevea.ifr_name)); + strlcpy(ifdevea.ifr_name, sizeof(ifdevea.ifr_name), ifr->ifr_name); if (ioctl(sockfd, SIOCRPHYSADDR, &ifdevea) < 0) { syslog(LOG_ERR, "Couldn't get h/w address for %s: %m", ifr->ifr_name); return 0; @@ -1200,7 +1200,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)); + strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0) continue; if ((ifreq.ifr_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK)) @@ -1286,9 +1286,9 @@ logwtmp(line, name, host) if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0) return; if (!fstat(fd, &buf)) { - (void)strncpy(ut.ut_line, line, sizeof(ut.ut_line)); - (void)strncpy(ut.ut_name, name, sizeof(ut.ut_name)); - (void)strncpy(ut.ut_host, host, sizeof(ut.ut_host)); + strlcpy(ut.ut_line, sizeof(ut.ut_line), line); + strlcpy(ut.ut_name, sizeof(ut.ut_name), name); + strlcpy(ut.ut_host, sizeof(ut.ut_host), host); (void)time(&ut.ut_time); if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp)) (void)ftruncate(fd, buf.st_size); @@ -1312,13 +1312,15 @@ lock(dev) { int fd, pid, n; char *p; + size_t l; if ((p = strrchr(dev, '/')) != NULL) dev = p + 1; - lock_file = malloc(strlen(LOCK_PREFIX) + strlen(dev) + 1); + l = strlen(LOCK_PREFIX) + strlen(dev) + 1; + lock_file = malloc(l); if (lock_file == NULL) novm("lock file name"); - strcat(strcpy(lock_file, LOCK_PREFIX), dev); + slprintf(lock_file, l, "%s%s, LOCK_PREFIX, dev); while ((fd = open(lock_file, O_EXCL | O_CREAT | O_RDWR, 0644)) < 0) { if (errno == EEXIST