From fdc0c58f5a318a320f15e922f4df879b6bd75c71 Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Fri, 19 Mar 1999 01:29:51 +0000 Subject: [PATCH] changed order of args to strlcpy/strlcat. removed unused note_debug_level. made some functions static. --- pppd/sys-NeXT.c | 40 +++++--------- pppd/sys-aix4.c | 20 +++---- pppd/sys-bsd.c | 22 ++++---- pppd/sys-linux.c | 62 +++++++++------------- pppd/sys-osf.c | 37 +++++-------- pppd/sys-sunos4.c | 22 ++++---- pppd/sys-svr4.c | 20 +++---- pppd/sys-ultrix.c | 130 +++++++++++++++++----------------------------- 8 files changed, 139 insertions(+), 214 deletions(-) diff --git a/pppd/sys-NeXT.c b/pppd/sys-NeXT.c index 373fb58..0a6645e 100644 --- a/pppd/sys-NeXT.c +++ b/pppd/sys-NeXT.c @@ -20,7 +20,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: sys-NeXT.c,v 1.14 1999/03/16 22:53:46 paulus Exp $"; +static char rcsid[] = "$Id: sys-NeXT.c,v 1.15 1999/03/19 01:29:40 paulus Exp $"; #endif #include @@ -125,7 +125,7 @@ sys_cleanup() struct ifreq ifr; if (if_is_up) { - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + 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; @@ -141,20 +141,6 @@ sys_cleanup() close(pppdev); } -/* - * note_debug_level - note a change in the debug level. - */ -void -note_debug_level() -{ - if (debug) { - info("Debug turned ON, Level %d", debug); - setlogmask(LOG_UPTO(LOG_DEBUG)); - } else { - setlogmask(LOG_UPTO(LOG_WARNING)); - } -} - /* * ppp_available - check whether the system has any ppp interfaces * (in fact we check whether we can do an ioctl on ppp0). @@ -169,7 +155,7 @@ ppp_available() if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1; /* can't tell - maybe we're not root */ - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), "ppp0"); + strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; close(s); @@ -603,7 +589,7 @@ ppp_send_config(unit, mtu, asyncmap, pcomp, accomp) u_int x; struct ifreq ifr; - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); ifr.ifr_mtu = mtu; if (ioctl(sockfd, SIOCSIFMTU, (caddr_t) &ifr) < 0) fatal("ioctl(SIOCSIFMTU): %m"); @@ -754,7 +740,7 @@ sifup(u) u_int x; struct npioctl npi; - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { error("ioctl (SIOCGIFFLAGS): %m"); return 0; @@ -805,7 +791,7 @@ sifdown(u) /* ignore errors, because ttyfd might have been closed by now. */ - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { error("ioctl (SIOCGIFFLAGS): %m"); rv = 0; @@ -840,7 +826,7 @@ sifaddr(u, o, h, m) struct ifreq ifr; ret = 1; - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); SET_SA_FAMILY(ifr.ifr_addr, AF_INET); ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = o; if (ioctl(sockfd, SIOCSIFADDR, (caddr_t) &ifr) < 0) { @@ -1029,7 +1015,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; - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name)); /* * Check that the interface is up, and not point-to-point * or loopback. @@ -1102,7 +1088,7 @@ ether_by_host(hostname, etherptr) /* * Now we can convert the returned string into an ethernet address. */ - strlcpy(path, sizeof(path), val.ni_namelist_val[0]); + strlcpy(path, val.ni_namelist_val[0], sizeof(path)); ni_free(conn); if ((thisptr = (struct ether_addr*)ether_aton(path)) == NULL) return 1; @@ -1162,7 +1148,7 @@ GetMask(addr) /* * Check that the interface is up, and not point-to-point or loopback. */ - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + 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)) @@ -1258,9 +1244,9 @@ logwtmp(line, name, host) if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0) return; if (!fstat(fd, &buf)) { - 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); + strlcpy(ut.ut_line, line, sizeof(ut.ut_line)); + strlcpy(ut.ut_name, name, sizeof(ut.ut_name)); + strlcpy(ut.ut_host, host, sizeof(ut.ut_host)); (void)time(&ut.ut_time); if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp)) (void)ftruncate(fd, buf.st_size); diff --git a/pppd/sys-aix4.c b/pppd/sys-aix4.c index 9c92e3f..fbe9bcc 100644 --- a/pppd/sys-aix4.c +++ b/pppd/sys-aix4.c @@ -21,7 +21,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: sys-aix4.c,v 1.17 1999/03/16 22:53:46 paulus Exp $"; +static char rcsid[] = "$Id: sys-aix4.c,v 1.18 1999/03/19 01:29:40 paulus Exp $"; #endif /* @@ -111,7 +111,7 @@ sys_cleanup() struct ifreq ifr; if (if_is_up) { - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + 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; @@ -664,7 +664,7 @@ ppp_send_config(unit, mtu, asyncmap, pcomp, accomp) int c; struct ifreq ifr; - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); ifr.ifr_mtu = mtu; if (ioctl(sockfd, SIOCSIFMTU, (caddr_t) &ifr) < 0) fatal("ioctl(SIOCSIFMTU): %m"); @@ -805,7 +805,7 @@ sifup(u) { struct ifreq ifr; - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { error("ioctl (SIOCGIFFLAGS): %m"); return 0; @@ -857,7 +857,7 @@ sifdown(u) ioctl(ttyfd, SIOCSETNPMODE, &npi); /* ignore errors, because ttyfd might have been closed by now. */ - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { error("ioctl (SIOCGIFFLAGS): %m"); rv = 0; @@ -891,7 +891,7 @@ sifaddr(u, o, h, m) struct ifreq ifr; ret = 1; - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); SET_SA_FAMILY(ifr.ifr_addr, AF_INET); if (m != 0) { info("Setting interface mask to %s\n", ip_ntoa(m)); @@ -1259,7 +1259,7 @@ GetMask(addr) /* * Check that the interface is up, and not point-to-point or loopback. */ - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + 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)) @@ -1289,9 +1289,9 @@ logwtmp(line, name, host) if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0) return; if (!fstat(fd, &buf)) { - 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); + strlcpy(ut.ut_line, line, sizeof(ut.ut_line)); + strlcpy(ut.ut_name, name, sizeof(ut.ut_name)); + strlcpy(ut.ut_host, host, sizeof(ut.ut_host)); (void)time(&ut.ut_time); if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp)) (void)ftruncate(fd, buf.st_size); diff --git a/pppd/sys-bsd.c b/pppd/sys-bsd.c index afb644e..717bcfe 100644 --- a/pppd/sys-bsd.c +++ b/pppd/sys-bsd.c @@ -21,7 +21,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: sys-bsd.c,v 1.38 1999/03/16 22:53:47 paulus Exp $"; +static char rcsid[] = "$Id: sys-bsd.c,v 1.39 1999/03/19 01:29:44 paulus Exp $"; /* $NetBSD: sys-bsd.c,v 1.1.1.3 1997/09/26 18:53:04 christos Exp $ */ #endif @@ -131,7 +131,7 @@ sys_cleanup() struct ifreq ifr; if (if_is_up) { - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + 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; @@ -188,7 +188,7 @@ ppp_available() if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1; /* can't tell */ - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), "ppp0"); + strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; close(s); @@ -668,7 +668,7 @@ ppp_send_config(unit, mtu, asyncmap, pcomp, accomp) u_int x; struct ifreq ifr; - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); ifr.ifr_mtu = mtu; if (ioctl(sockfd, SIOCSIFMTU, (caddr_t) &ifr) < 0) fatal("ioctl(SIOCSIFMTU): %m"); @@ -852,7 +852,7 @@ sifup(u) { struct ifreq ifr; - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { error("ioctl (SIOCGIFFLAGS): %m"); return 0; @@ -903,7 +903,7 @@ sifdown(u) ioctl(ppp_fd, PPPIOCSNPMODE, (caddr_t) &npi); /* ignore errors, because ppp_fd might have been closed by now. */ - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { error("ioctl (SIOCGIFFLAGS): %m"); rv = 0; @@ -938,7 +938,7 @@ sifaddr(u, o, h, m) struct ifaliasreq ifra; struct ifreq ifr; - strlcpy(ifra.ifra_name, sizeof(ifra.ifra_name), ifname); + 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); @@ -949,7 +949,7 @@ sifaddr(u, o, h, m) } else BZERO(&ifra.ifra_mask, sizeof(ifra.ifra_mask)); BZERO(&ifr, sizeof(ifr)); - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(sockfd, SIOCDIFADDR, (caddr_t) &ifr) < 0) { if (errno != EADDRNOTAVAIL) warn("Couldn't remove interface address: %m"); @@ -978,7 +978,7 @@ cifaddr(u, o, h) struct ifaliasreq ifra; ifaddrs[0] = 0; - strlcpy(ifra.ifra_name, sizeof(ifra.ifra_name), ifname); + 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); @@ -1256,7 +1256,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; - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name)); /* * Check that the interface is up, and not point-to-point * or loopback. @@ -1355,7 +1355,7 @@ GetMask(addr) /* * Check that the interface is up, and not point-to-point or loopback. */ - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + 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)) diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index 0ed73fd..3a5890a 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -146,6 +146,8 @@ static int defaultroute_exists (struct rtentry *rt); static int get_ether_addr (u_int32_t ipaddr, struct sockaddr *hwaddr, char *name); static void decode_version (char *buf, int *version, int *mod, int *patch); +static int set_kdebugflag(int level); +static int ppp_registered(void); extern u_char inpacket_buf[]; /* borrowed from main.c */ @@ -251,7 +253,7 @@ void sys_init(void) * * sys_cleanup - restore any system state we modified before exiting: * mark the interface down, delete default route and/or proxy arp entry. - * This should call die() because it's called from die(). + * This shouldn't call die() because it's called from die(). */ void sys_cleanup(void) @@ -283,28 +285,12 @@ sys_close(void) closelog(); } -/******************************************************************** - * - * note_debug_level - note a change in the debug level. - */ - -void note_debug_level (void) -{ - if (debug) { - SYSDEBUG ((LOG_INFO, "Debug turned ON, Level %d", debug)); - setlogmask(LOG_UPTO(LOG_DEBUG)); - } - else { - setlogmask(LOG_UPTO(LOG_WARNING)); - } -} - /******************************************************************** * * set_kdebugflag - Define the debugging level for the kernel */ -int set_kdebugflag (int requested_level) +static int set_kdebugflag (int requested_level) { if (ioctl(ppp_fd, PPPIOCSDEBUG, &requested_level) < 0) { if ( ! ok_error (errno) ) @@ -660,7 +646,7 @@ void set_up_tty(int tty_fd, int local) fatal("tcsetattr: %m"); baud_rate = baud_rate_of(speed); - restore_term = TRUE; + restore_term = 1; } /******************************************************************** @@ -859,7 +845,7 @@ void ppp_send_config (int unit,int mtu,u_int32_t asyncmap,int pcomp,int accomp) * Set the MTU and other parameters for the ppp device */ memset (&ifr, '\0', sizeof (ifr)); - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); ifr.ifr_mtu = mtu; if (ioctl(sock_fd, SIOCSIFMTU, (caddr_t) &ifr) < 0) @@ -1020,7 +1006,7 @@ static int path_to_procfs (void) fp = fopen(MOUNTED, "r"); if (fp == NULL) { /* Default the mount location of /proc */ - strlcpy (route_buffer, sizeof (route_buffer), "/proc"); + strlcpy (route_buffer, "/proc", sizeof (route_buffer)); return 1; } @@ -1034,7 +1020,7 @@ static int path_to_procfs (void) if (mntent == 0) return 0; - strlcpy(route_buffer, sizeof (route_buffer), mntent->mnt_dir); + strlcpy(route_buffer, mntent->mnt_dir, sizeof (route_buffer)); return 1; } @@ -1049,7 +1035,7 @@ static char *path_to_route (void) error("proc file system not mounted"); return 0; } - strlcat (route_buffer, sizeof(route_buffer), "/net/route"); + strlcat (route_buffer, "/net/route", sizeof(route_buffer)); return (route_buffer); } @@ -1386,7 +1372,7 @@ static int get_ether_addr (u_int32_t ipaddr, for (ifr = ifc.ifc_req; ifr < ifend; ifr++) { if (ifr->ifr_addr.sa_family == AF_INET) { ina = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr; - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name)); SYSDEBUG ((LOG_DEBUG, "proxy arp: examining interface %s", ifreq.ifr_name)); /* @@ -1497,7 +1483,7 @@ u_int32_t GetMask (u_int32_t addr) /* * Check that the interface is up, and not point-to-point nor loopback. */ - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name)); if (ioctl(sock_fd, SIOCGIFFLAGS, &ifreq) < 0) continue; @@ -1547,7 +1533,7 @@ static void decode_version (char *buf, int *version, * Procedure to determine if the PPP line discipline is registered. */ -int +static int ppp_registered(void) { int local_fd; @@ -1615,7 +1601,7 @@ int ppp_available(void) if (s < 0) return 0; - strlcpy (ifr.ifr_name, sizeof (ifr.ifr_name), "ppp0"); + strlcpy (ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; /* * If the device did not exist then attempt to create one by putting the @@ -1624,7 +1610,7 @@ int ppp_available(void) */ if (!ok) { if (ppp_registered()) { - strlcpy (ifr.ifr_name, sizeof (ifr.ifr_name), "ppp0"); + strlcpy (ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; } } @@ -1727,10 +1713,10 @@ void logwtmp (const char *line, const char *name, const char *host) memset(&ut, 0, sizeof(ut)); if (ut.ut_id[0] == 0) - strlcpy(ut.ut_id, sizeof(ut.ut_id), line + 3); + strlcpy(ut.ut_id, line + 3, sizeof(ut.ut_id)); - strlcpy(ut.ut_user, sizeof(ut.ut_user), name); - strlcpy(ut.ut_line, sizeof(ut.ut_line), line); + strlcpy(ut.ut_user, name, sizeof(ut.ut_user)); + strlcpy(ut.ut_line, line, sizeof(ut.ut_line)); time(&ut.ut_time); @@ -1739,7 +1725,7 @@ void logwtmp (const char *line, const char *name, const char *host) /* Insert the host name if one is supplied */ if (*host) - strlcpy (ut.ut_host, sizeof(ut.ut_host), host); + strlcpy (ut.ut_host, host, sizeof(ut.ut_host)); /* Insert the IP address of the remote system if IP is enabled */ if (ipcp_protent.enabled_flag && ipcp_hisoptions[0].neg_addr) @@ -1939,7 +1925,7 @@ int sifup (int u) struct ifreq ifr; memset (&ifr, '\0', sizeof (ifr)); - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { if (! ok_error (errno)) error("ioctl (SIOCGIFFLAGS): %m(%d)", errno); @@ -1968,7 +1954,7 @@ int sifdown (int u) if_is_up = 0; memset (&ifr, '\0', sizeof (ifr)); - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(sock_fd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { if (! ok_error (errno)) error("ioctl (SIOCGIFFLAGS): %m(%d)", errno); @@ -2003,7 +1989,7 @@ int sifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr, SET_SA_FAMILY (ifr.ifr_dstaddr, AF_INET); SET_SA_FAMILY (ifr.ifr_netmask, AF_INET); - strlcpy (ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); /* * Set our IP address */ @@ -2240,7 +2226,7 @@ int sipxfaddr (int unit, unsigned long int network, unsigned char * node ) } else { memset (&ifr, '\0', sizeof (ifr)); - strlcpy (ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy (ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); memcpy (sipx->sipx_node, node, IPX_NODE_LEN); sipx->sipx_family = AF_IPX; @@ -2291,7 +2277,7 @@ int cipxfaddr (int unit) } else { memset (&ifr, '\0', sizeof (ifr)); - strlcpy (ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy (ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); sipx->sipx_type = IPX_FRAME_ETHERII; sipx->sipx_action = IPX_DLTITF; @@ -2365,7 +2351,7 @@ sys_check_options(void) */ while (ipxcp_protent.enabled_flag) { if (path_to_procfs()) { - strlcat (route_buffer, sizeof(route_buffer), "/net/ipx_interface"); + strlcat (route_buffer, "/net/ipx_interface", sizeof(route_buffer)); if (lstat (route_buffer, &stat_buf) >= 0) break; } diff --git a/pppd/sys-osf.c b/pppd/sys-osf.c index 9e82ae4..30930b2 100644 --- a/pppd/sys-osf.c +++ b/pppd/sys-osf.c @@ -26,7 +26,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: sys-osf.c,v 1.20 1999/03/16 22:53:48 paulus Exp $"; +static char rcsid[] = "$Id: sys-osf.c,v 1.21 1999/03/19 01:29:46 paulus Exp $"; #endif #include @@ -225,19 +225,6 @@ daemon(nochdir, noclose) return 0; } -/* - * note_debug_level - note a change in the debug level. - */ -void -note_debug_level() -{ - if (debug) { - setlogmask(LOG_UPTO(LOG_DEBUG)); - } else { - setlogmask(LOG_UPTO(LOG_WARNING)); - } -} - /* * ppp_available - check whether the system has any ppp interfaces */ @@ -1081,7 +1068,7 @@ sifup(u) { struct ifreq ifr; - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { error("Couldn't mark interface up (get): %m"); return 0; @@ -1104,7 +1091,7 @@ sifdown(u) { struct ifreq ifr; - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { error("Couldn't mark interface down (get): %m"); return 0; @@ -1167,7 +1154,7 @@ sifaddr(u, o, h, m) /* flush old address, if any */ bzero(&ifr, sizeof (ifr)); - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); SET_SA_FAMILY(ifr.ifr_addr, AF_INET); ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = o; if ((ioctl(sockfd, (int)SIOCDIFADDR, (caddr_t) &ifr) < 0) @@ -1177,7 +1164,7 @@ sifaddr(u, o, h, m) } bzero(&addreq, sizeof (addreq)); - strlcpy(addreq.ifra_name, sizeof (addreq.ifra_name), ifname); + strlcpy(addreq.ifra_name, ifname, sizeof (addreq.ifra_name)); SET_SA_FAMILY(addreq.ifra_addr, AF_INET); SET_SA_FAMILY(addreq.ifra_broadaddr, AF_INET); ((struct sockaddr_in *)&addreq.ifra_addr)->sin_addr.s_addr = o; @@ -1222,7 +1209,7 @@ cifaddr(u, o, h) ifaddrs[0] = 0; ifaddrs[1] = 0; bzero(&ifr, sizeof (ifr)); - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); SET_SA_FAMILY(ifr.ifr_addr, AF_INET); ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = o; if (ioctl(sockfd, (int)SIOCDIFADDR, (caddr_t) &ifr) < 0) { @@ -1372,7 +1359,7 @@ get_ether_addr(ipaddr, hwaddr) * Check that the interface is up, and not point-to-point * or loopback. */ - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0) continue; if ((ifreq.ifr_flags & @@ -1401,7 +1388,7 @@ get_ether_addr(ipaddr, hwaddr) return 0; info("found interface %s for proxy arp", ifr->ifr_name); - strlcpy(ifdevreq.ifr_name, sizeof(ifdevreq.ifr_name), ifr->ifr_name); + strlcpy(ifdevreq.ifr_name, ifr->ifr_name, sizeof(ifdevreq.ifr_name)); if (ioctl(sockfd, (int)SIOCRPHYSADDR, &ifdevreq) < 0) { perror("ioctl(SIOCRPHYSADDR)"); @@ -1426,9 +1413,9 @@ logwtmp(line, name, host) if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0) return; if (!fstat(fd, &buf)) { - 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); + strlcpy(ut.ut_line, line, sizeof(ut.ut_line)); + strlcpy(ut.ut_name, name, sizeof(ut.ut_name)); + strlcpy(ut.ut_host, host, sizeof(ut.ut_host)); (void)time(&ut.ut_time); if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp)) (void)ftruncate(fd, buf.st_size); @@ -1485,7 +1472,7 @@ GetMask(addr) /* * Check that the interface is up, and not point-to-point or loopback. */ - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + 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)) diff --git a/pppd/sys-sunos4.c b/pppd/sys-sunos4.c index 4011742..ba2cc3c 100644 --- a/pppd/sys-sunos4.c +++ b/pppd/sys-sunos4.c @@ -26,7 +26,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: sys-sunos4.c,v 1.15 1999/03/16 22:53:48 paulus Exp $"; +static char rcsid[] = "$Id: sys-sunos4.c,v 1.16 1999/03/19 01:29:47 paulus Exp $"; #endif #include @@ -729,7 +729,7 @@ ppp_send_config(unit, mtu, asyncmap, pcomp, accomp) /* set mtu for ip as well */ memset(&ifr, 0, sizeof(ifr)); - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); ifr.ifr_metric = link_mtu; if (ioctl(sockfd, SIOCSIFMTU, &ifr) < 0) { error("Couldn't set IP MTU: %m"); @@ -880,7 +880,7 @@ sifup(u) { struct ifreq ifr; - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { error("Couldn't mark interface up (get): %m"); return 0; @@ -903,7 +903,7 @@ sifdown(u) { struct ifreq ifr; - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { error("Couldn't mark interface down (get): %m"); return 0; @@ -952,7 +952,7 @@ sifaddr(u, o, h, m) struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); ifr.ifr_addr.sa_family = AF_INET; INET_ADDR(ifr.ifr_addr) = m; if (ioctl(sockfd, SIOCSIFNETMASK, &ifr) < 0) { @@ -1141,7 +1141,7 @@ get_ether_addr(ipaddr, hwaddr) * Check that the interface is up, and not point-to-point * or loopback. */ - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, &ifreq) < 0) continue; if ((ifreq.ifr_flags & @@ -1174,7 +1174,7 @@ get_ether_addr(ipaddr, hwaddr) error("Couldn't open /dev/nit: %m"); return 0; } - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name)); if (ioctl(nit_fd, NIOCBIND, &ifreq) < 0 || ioctl(nit_fd, SIOCGIFADDR, &ifreq) < 0) { error("Couldn't get hardware address for %s: %m", @@ -1214,9 +1214,9 @@ logwtmp(line, name, host) if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0) return; if (!fstat(fd, &buf)) { - 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); + strlcpy(ut.ut_line, line, sizeof(ut.ut_line)); + strlcpy(ut.ut_name, name, sizeof(ut.ut_name)); + strlcpy(ut.ut_host, host, sizeof(ut.ut_host)); (void)time(&ut.ut_time); if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp)) (void)ftruncate(fd, buf.st_size); @@ -1274,7 +1274,7 @@ GetMask(addr) /* * Check that the interface is up, and not point-to-point or loopback. */ - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + 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)) diff --git a/pppd/sys-svr4.c b/pppd/sys-svr4.c index e6d3d67..c87c9d0 100644 --- a/pppd/sys-svr4.c +++ b/pppd/sys-svr4.c @@ -26,7 +26,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: sys-svr4.c,v 1.26 1999/03/16 22:53:48 paulus Exp $"; +static char rcsid[] = "$Id: sys-svr4.c,v 1.27 1999/03/19 01:29:50 paulus Exp $"; #endif #include @@ -834,7 +834,7 @@ ppp_send_config(unit, mtu, asyncmap, pcomp, accomp) /* set the MTU for IP as well */ memset(&ifr, 0, sizeof(ifr)); - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); ifr.ifr_metric = link_mtu; if (ioctl(ipfd, SIOCSIFMTU, &ifr) < 0) { error("Couldn't set IP MTU: %m"); @@ -1016,7 +1016,7 @@ sifup(u) { struct ifreq ifr; - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(ipfd, SIOCGIFFLAGS, &ifr) < 0) { error("Couldn't mark interface up (get): %m"); return 0; @@ -1041,7 +1041,7 @@ sifdown(u) if (ipmuxid < 0) return 1; - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(ipfd, SIOCGIFFLAGS, &ifr) < 0) { error("Couldn't mark interface down (get): %m"); return 0; @@ -1089,7 +1089,7 @@ sifaddr(u, o, h, m) int ret = 1; memset(&ifr, 0, sizeof(ifr)); - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); ifr.ifr_addr.sa_family = AF_INET; INET_ADDR(ifr.ifr_addr) = m; if (ioctl(ipfd, SIOCSIFNETMASK, &ifr) < 0) { @@ -1301,7 +1301,7 @@ get_ether_addr(ipaddr, hwaddr) /* * Check that the interface is up, and not point-to-point or loopback. */ - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name)); if (ioctl(ipfd, SIOCGIFFLAGS, &ifreq) < 0) continue; if ((ifreq.ifr_flags & @@ -1550,7 +1550,7 @@ GetMask(addr) /* * Check that the interface is up, and not point-to-point or loopback. */ - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name)); if (ioctl(ipfd, SIOCGIFFLAGS, &ifreq) < 0) continue; if ((ifreq.ifr_flags & (IFF_UP|IFF_POINTOPOINT|IFF_LOOPBACK)) @@ -1579,9 +1579,9 @@ logwtmp(line, name, host) if (name[0] != 0) { /* logging in */ - strlcpy(utmpx.ut_user, sizeof(utmpx.ut_user), name); - strlcpy(utmpx.ut_id, sizeof(utmpx.ut_id), ifname); - strlcpy(utmpx.ut_line, sizeof(utmpx.ut_line), line); + strlcpy(utmpx.ut_user, name, sizeof(utmpx.ut_user)); + strlcpy(utmpx.ut_id, ifname, sizeof(utmpx.ut_id)); + strlcpy(utmpx.ut_line, line, sizeof(utmpx.ut_line)); utmpx.ut_pid = getpid(); utmpx.ut_type = USER_PROCESS; } else { diff --git a/pppd/sys-ultrix.c b/pppd/sys-ultrix.c index b9da26b..e4ed3e7 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.27 1999/03/16 22:53:49 paulus Exp $"; +static char rcsid[] = "$Id: sys-ultrix.c,v 1.28 1999/03/19 01:29:51 paulus Exp $"; #endif /* @@ -91,10 +91,8 @@ void sys_init() { /* Get an internet socket for doing socket ioctl's on. */ - if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { - error("Couldn't create IP socket: %m"); - die(1); - } + if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + fatal("Couldn't create IP socket: %m"); FD_ZERO(&in_fds); max_in_fd = 0; @@ -103,7 +101,7 @@ sys_init() /* * sys_cleanup - restore any system state we modified before exiting: * mark the interface down, delete default route and/or proxy arp entry. - * This should call die() because it's called from die(). + * This shouldn't call die() because it's called from die(). */ void sys_cleanup() @@ -111,7 +109,7 @@ sys_cleanup() struct ifreq ifr; if (if_is_up) { - strlcpy(ifr.ifr_name, sizeof(ifr.ifr_name), ifname); + 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; @@ -191,7 +189,7 @@ ppp_available() if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) return 1; /* can't tell */ - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), "ppp0"); + strlcpy(ifr.ifr_name, "ppp0", sizeof (ifr.ifr_name)); ok = ioctl(s, SIOCGIFFLAGS, (caddr_t) &ifr) >= 0; close(s); @@ -215,22 +213,16 @@ establish_ppp(fd) /* * Save the old line discipline of fd, and set it to PPP. */ - if (ioctl(fd, TIOCGETD, &initdisc) < 0) { - error("ioctl(TIOCGETD): %m"); - die(1); - } - if (ioctl(fd, TIOCSETD, &pppdisc) < 0) { - error("ioctl(TIOCSETD): %m"); - die(1); - } + if (ioctl(fd, TIOCGETD, &initdisc) < 0) + fatal("ioctl(TIOCGETD): %m"); + if (ioctl(fd, TIOCSETD, &pppdisc) < 0) + fatal("ioctl(TIOCSETD): %m"); /* * Find out which interface we were given. */ - if (ioctl(fd, PPPIOCGUNIT, &ifunit) < 0) { - error("ioctl(PPPIOCGUNIT): %m"); - die(1); - } + if (ioctl(fd, PPPIOCGUNIT, &ifunit) < 0) { + fatal("ioctl(PPPIOCGUNIT): %m"); ppp_fd = fd; @@ -443,10 +435,8 @@ set_up_tty(fd, local) int speed, x; struct termios tios; - if (tcgetattr(fd, &tios) < 0) { - error("tcgetattr: %m"); - die(1); - } + if (tcgetattr(fd, &tios) < 0) + fatal("tcgetattr: %m"); if (!restore_term) { inittermios = tios; @@ -486,17 +476,12 @@ set_up_tty(fd, local) * We can't proceed if the serial port speed is B0, * since that implies that the serial port is disabled. */ - if (speed == B0) { - error("Baud rate for %s is 0; need explicit baud rate", - devnam); - die(1); - } + if (speed == B0) + fatal("Baud rate for %s is 0; need explicit baud rate", devnam); } - if (tcsetattr(fd, TCSAFLUSH, &tios) < 0) { - error("tcsetattr: %m"); - die(1); - } + if (tcsetattr(fd, TCSAFLUSH, &tios) < 0) + fatal("tcsetattr: %m"); x = 0; if (ioctl(fd, (crtscts > 0 || modem)? TIOCMODEM: TIOCNMODEM, &x) < 0) @@ -505,7 +490,7 @@ set_up_tty(fd, local) warn("TIOC(N)CAR: %m"); baud_rate = inspeed = baud_rate_of(speed); - restore_term = TRUE; + restore_term = 1; } /* @@ -529,7 +514,7 @@ restore_tty(fd) if (errno != ENXIO) warn("tcsetattr: %m"); ioctl(fd, TIOCSWINSZ, &wsinfo); - restore_term = FALSE; + restore_term = 0; } } @@ -641,10 +626,8 @@ wait_time(timo) int n; n = select(0, NULL, NULL, NULL, timo); - if (n < 0 && errno != EINTR) { - error("select: %m"); - die(1); - } + if (n < 0 && errno != EINTR) + fatal("select: %m"); } #endif @@ -660,8 +643,7 @@ read_packet(buf) if ((len = read(ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) { if (errno == EWOULDBLOCK || errno == EINTR) return -1; - error("read(fd): %m"); - die(1); + fatal("read(fd): %m"); } return len; } @@ -691,26 +673,18 @@ ppp_send_config(unit, mtu, asyncmap, pcomp, accomp) { u_int x; - if (ioctl(ppp_fd, PPPIOCSMTU, &mtu) < 0) { - error("ioctl(PPPIOCSMTU): %m"); - quit(); - } + if (ioctl(ppp_fd, PPPIOCSMTU, &mtu) < 0) + fatal("ioctl(PPPIOCSMTU): %m"); - if (ioctl(ppp_fd, PPPIOCSASYNCMAP, (caddr_t) &asyncmap) < 0) { - error("ioctl(PPPIOCSASYNCMAP): %m"); - quit(); - } + if (ioctl(ppp_fd, PPPIOCSASYNCMAP, (caddr_t) &asyncmap) < 0) + fatal("ioctl(PPPIOCSASYNCMAP): %m"); - if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) { - error("ioctl (PPPIOCGFLAGS): %m"); - quit(); - } + if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) + fatal("ioctl (PPPIOCGFLAGS): %m"); x = pcomp? x | SC_COMP_PROT: x &~ SC_COMP_PROT; x = accomp? x | SC_COMP_AC: x &~ SC_COMP_AC; - if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) { - error("ioctl(PPPIOCSFLAGS): %m"); - quit(); - } + if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) + fatal("ioctl(PPPIOCSFLAGS): %m"); } @@ -739,23 +713,15 @@ ppp_recv_config(unit, mru, asyncmap, pcomp, accomp) { int x; - if (ioctl(ppp_fd, PPPIOCSMRU, (caddr_t) &mru) < 0) { - error("ioctl(PPPIOCSMRU): %m"); - quit(); - } - if (ioctl(ppp_fd, PPPIOCSRASYNCMAP, (caddr_t) &asyncmap) < 0) { - error("ioctl(PPPIOCSRASYNCMAP): %m"); - quit(); - } - if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) { - error("ioctl (PPPIOCGFLAGS): %m"); - quit(); - } + if (ioctl(ppp_fd, PPPIOCSMRU, (caddr_t) &mru) < 0) + fatal("ioctl(PPPIOCSMRU): %m"); + if (ioctl(ppp_fd, PPPIOCSRASYNCMAP, (caddr_t) &asyncmap) < 0) + fatal("ioctl(PPPIOCSRASYNCMAP): %m"); + if (ioctl(ppp_fd, PPPIOCGFLAGS, (caddr_t) &x) < 0) + fatal("ioctl (PPPIOCGFLAGS): %m"); x = !accomp? x | SC_REJ_COMP_AC: x &~ SC_REJ_COMP_AC; - if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) { - error("ioctl(PPPIOCSFLAGS): %m"); - quit(); - } + if (ioctl(ppp_fd, PPPIOCSFLAGS, (caddr_t) &x) < 0) + fatal("ioctl(PPPIOCSFLAGS): %m"); } /* @@ -863,7 +829,7 @@ sifup(u) { struct ifreq ifr; - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { error("ioctl (SIOCGIFFLAGS): %m"); return 0; @@ -914,7 +880,7 @@ sifdown(u) ioctl(ppp_fd, PPPIOCSNPMODE, (caddr_t) &npi); /* ignore errors, because ppp_fd might have been closed by now. */ - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t) &ifr) < 0) { error("ioctl (SIOCGIFFLAGS): %m"); rv = 0; @@ -949,7 +915,7 @@ sifaddr(u, o, h, m) struct ifreq ifr; ret = 1; - strlcpy(ifr.ifr_name, sizeof (ifr.ifr_name), ifname); + strlcpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name)); SET_SA_FAMILY(ifr.ifr_addr, AF_INET); if (m != 0) { ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr = m; @@ -1131,7 +1097,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; - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + strlcpy(ifreq.ifr_name, ifr->ifr_name, sizeof(ifreq.ifr_name)); /* * Check that the interface is up, and not point-to-point * or loopback. @@ -1162,7 +1128,7 @@ get_ether_addr(ipaddr, hwaddr) /* * Grab the physical address for this interface. */ - strlcpy(ifdevea.ifr_name, sizeof(ifdevea.ifr_name), ifr->ifr_name); + strlcpy(ifdevea.ifr_name, ifr->ifr_name, sizeof(ifdevea.ifr_name)); if (ioctl(sockfd, SIOCRPHYSADDR, &ifdevea) < 0) { error("Couldn't get h/w address for %s: %m", ifr->ifr_name); return 0; @@ -1223,7 +1189,7 @@ GetMask(addr) /* * Check that the interface is up, and not point-to-point or loopback. */ - strlcpy(ifreq.ifr_name, sizeof(ifreq.ifr_name), ifr->ifr_name); + 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)) @@ -1309,9 +1275,9 @@ logwtmp(line, name, host) if ((fd = open(WTMPFILE, O_WRONLY|O_APPEND, 0)) < 0) return; if (!fstat(fd, &buf)) { - 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); + strlcpy(ut.ut_line, line, sizeof(ut.ut_line)); + strlcpy(ut.ut_name, name, sizeof(ut.ut_name)); + strlcpy(ut.ut_host, host, sizeof(ut.ut_host)); (void)time(&ut.ut_time); if (write(fd, (char *)&ut, sizeof(struct utmp)) != sizeof(struct utmp)) (void)ftruncate(fd, buf.st_size); -- 2.39.2