From 92f9578b82a0c9e928fce701e8606e39b8337a54 Mon Sep 17 00:00:00 2001 From: millert Date: Sun, 15 Dec 1996 23:20:32 +0000 Subject: [PATCH] Use inet_aton() instead of inet_addr() --- usr.sbin/pppd/Makefile | 6 +++--- usr.sbin/pppd/auth.c | 21 +++++++++++---------- usr.sbin/pppd/options.c | 24 +++++++++++++----------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/usr.sbin/pppd/Makefile b/usr.sbin/pppd/Makefile index f8552ded808..33fcbf8190a 100644 --- a/usr.sbin/pppd/Makefile +++ b/usr.sbin/pppd/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.6 1996/07/20 12:02:03 joshd Exp $ +# $OpenBSD: Makefile,v 1.7 1996/12/15 23:20:32 millert Exp $ # $NetBSD: Makefile,v 1.12 1996/03/19 03:03:04 jtc Exp $ PROG= pppd -SRCS= main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c md5.c ccp.c \ +SRCS= main.c magic.c fsm.c lcp.c ipcp.c upap.c chap.c ccp.c \ auth.c options.c sys-bsd.c demand.c gencode.c grammar.c scanner.c \ - nametoaddr.c optimize.c bpf_filter.c chap_ms.c ipxcp.c md4.c + nametoaddr.c optimize.c bpf_filter.c chap_ms.c ipxcp.c .PATH: ${.CURDIR}/../../lib/libpcap ${.CURDIR}/../../sys/net MAN= pppd.8 SUBDIR= pppstats chat diff --git a/usr.sbin/pppd/auth.c b/usr.sbin/pppd/auth.c index 765e2c7ba60..600c69fc1c0 100644 --- a/usr.sbin/pppd/auth.c +++ b/usr.sbin/pppd/auth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth.c,v 1.4 1996/07/20 12:02:04 joshd Exp $ */ +/* $OpenBSD: auth.c,v 1.5 1996/12/15 23:20:33 millert Exp $ */ /* * auth.c - PPP authentication and phase control. @@ -35,7 +35,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: auth.c,v 1.4 1996/07/20 12:02:04 joshd Exp $"; +static char rcsid[] = "$OpenBSD: auth.c,v 1.5 1996/12/15 23:20:33 millert Exp $"; #endif #include @@ -1068,8 +1068,9 @@ ip_addr_check(addr, addrs) u_int32_t addr; struct wordlist *addrs; { - u_int32_t a, mask, ah; - int accept; + u_int32_t mask, ah; + struct in_addr ina; + int accept, r = 1; char *ptr_word, *ptr_mask; struct hostent *hp; struct netent *np; @@ -1111,17 +1112,17 @@ ip_addr_check(addr, addrs) hp = gethostbyname(ptr_word); if (hp != NULL && hp->h_addrtype == AF_INET) { - a = *(u_int32_t *)hp->h_addr; + ina.s_addr = *(u_int32_t *)hp->h_addr; mask = ~ (u_int32_t) 0; /* are we sure we want this? */ } else { np = getnetbyname (ptr_word); if (np != NULL && np->n_addrtype == AF_INET) - a = htonl (*(u_int32_t *)np->n_net); + ina.s_addr = htonl (*(u_int32_t *)np->n_net); else - a = inet_addr (ptr_word); + r = inet_aton (ptr_word, &ina); if (ptr_mask == NULL) { /* calculate appropriate mask for net */ - ah = ntohl(a); + ah = ntohl(ina.s_addr); if (IN_CLASSA(ah)) mask = IN_CLASSA_NET; else if (IN_CLASSB(ah)) @@ -1134,12 +1135,12 @@ ip_addr_check(addr, addrs) if (ptr_mask != NULL) *ptr_mask = '/'; - if (a == -1L) + if (r == 0) syslog (LOG_WARNING, "unknown host %s in auth. address list", addrs->word); else - if (((addr ^ a) & htonl(mask)) == 0) + if (((addr ^ ina.s_addr) & htonl(mask)) == 0) return accept; } return 0; /* not in list => can't have it */ diff --git a/usr.sbin/pppd/options.c b/usr.sbin/pppd/options.c index a47eedd33ec..d789c32e0d1 100644 --- a/usr.sbin/pppd/options.c +++ b/usr.sbin/pppd/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.4 1996/07/20 12:02:13 joshd Exp $ */ +/* $OpenBSD: options.c,v 1.5 1996/12/15 23:20:34 millert Exp $ */ /* * options.c - handles option processing for PPP. @@ -20,7 +20,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: options.c,v 1.4 1996/07/20 12:02:13 joshd Exp $"; +static char rcsid[] = "$OpenBSD: options.c,v 1.5 1996/12/15 23:20:34 millert Exp $"; #endif #include @@ -1482,6 +1482,7 @@ setipaddr(arg) { struct hostent *hp; char *colon; + struct in_addr ina; u_int32_t local, remote; ipcp_options *wo = &ipcp_wantoptions[0]; @@ -1496,7 +1497,7 @@ setipaddr(arg) */ if (colon != arg) { *colon = '\0'; - if ((local = inet_addr(arg)) == -1) { + if (inet_aton(arg, &ina) == 0) { if ((hp = gethostbyname(arg)) == NULL) { option_error("unknown host: %s", arg); return -1; @@ -1507,7 +1508,8 @@ setipaddr(arg) our_name[MAXNAMELEN-1] = 0; } } - } + } else + local = ina.s_addr; if (bad_ip_adrs(local)) { option_error("bad local IP address %s", ip_ntoa(local)); return -1; @@ -1521,7 +1523,7 @@ setipaddr(arg) * If colon last character, then no remote addr. */ if (*++colon != '\0') { - if ((remote = inet_addr(colon)) == -1) { + if (inet_aton(colon, &ina) == 0) { if ((hp = gethostbyname(colon)) == NULL) { option_error("unknown host: %s", colon); return -1; @@ -1532,7 +1534,8 @@ setipaddr(arg) remote_name[MAXNAMELEN-1] = 0; } } - } + } else + remote = ina.s_addr; if (bad_ip_adrs(remote)) { option_error("bad remote IP address %s", ip_ntoa(remote)); return -1; @@ -1585,14 +1588,14 @@ static int setnetmask(argv) char **argv; { - u_int32_t mask; + struct in_addr ina; - if ((mask = inet_addr(*argv)) == -1 || (netmask & ~mask) != 0) { + if (inet_aton(*argv, &ina) == 0 || (netmask & ~ina.s_addr) != 0) { option_error("invalid netmask value '%s'", *argv); return 0; } - netmask = mask; + netmask = ina.s_addr; return (1); } @@ -2210,8 +2213,7 @@ setdnsaddr(argv) u_int32_t dns; struct hostent *hp; - dns = inet_addr(*argv); - if (dns == -1) { + if (inet_aton(*argv, &dns) == 0) { if ((hp = gethostbyname(*argv)) == NULL) { option_error("invalid address parameter '%s' for ms-dns option", *argv); -- 2.20.1