From baba1a14808102f4260db32fc7f608b2d01a4938 Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 21 Aug 2024 14:57:05 +0000 Subject: [PATCH] Mechanically change inet_aton to inet_pton. This could use getaddrinfo in places but the code is just too crufty and my joo janta's turned black immediately. OK deraadt --- usr.sbin/pppd/auth.c | 8 ++++---- usr.sbin/pppd/options.c | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/usr.sbin/pppd/auth.c b/usr.sbin/pppd/auth.c index 2919a87799c..1fd2b32f3b2 100644 --- a/usr.sbin/pppd/auth.c +++ b/usr.sbin/pppd/auth.c @@ -1,4 +1,4 @@ -/* $OpenBSD: auth.c,v 1.42 2024/08/10 05:32:28 jsg Exp $ */ +/* $OpenBSD: auth.c,v 1.43 2024/08/21 14:57:05 florian Exp $ */ /* * auth.c - PPP authentication and phase control. @@ -972,7 +972,7 @@ set_allowed_addrs(int unit, struct wordlist *addrs) hp = gethostbyname(p); if (hp != NULL && hp->h_addrtype == AF_INET) wo->hisaddr = *(u_int32_t *)hp->h_addr; - else if (inet_aton(p, &ina) == 1) + else if (inet_pton(AF_INET, p, &ina) == 1) wo->hisaddr = ina.s_addr; } } @@ -1038,7 +1038,7 @@ ip_addr_check(u_int32_t addr, struct wordlist *addrs) if (hp != NULL && hp->h_addrtype == AF_INET) { ina.s_addr = *(u_int32_t *)hp->h_addr; } else { - r = inet_aton (ptr_word, &ina); + r = inet_pton(AF_INET, ptr_word, &ina); if (ptr_mask == NULL) { /* calculate appropriate mask for net */ ah = ntohl(ina.s_addr); @@ -1054,7 +1054,7 @@ ip_addr_check(u_int32_t addr, struct wordlist *addrs) if (ptr_mask != NULL) *ptr_mask = '/'; - if (r == 0) + if (r != 1) syslog (LOG_WARNING, "unknown host %s in auth. address list", addrs->word); diff --git a/usr.sbin/pppd/options.c b/usr.sbin/pppd/options.c index 0df6215d2bf..f17783dfcf0 100644 --- a/usr.sbin/pppd/options.c +++ b/usr.sbin/pppd/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.32 2024/08/10 05:32:28 jsg Exp $ */ +/* $OpenBSD: options.c,v 1.33 2024/08/21 14:57:05 florian Exp $ */ /* * options.c - handles option processing for PPP. @@ -42,6 +42,10 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include +#include +#include + #include #include #include @@ -53,8 +57,6 @@ #include #include #include -#include -#include #include #include #ifdef PPP_FILTER @@ -1565,7 +1567,7 @@ setipaddr(char *arg) */ if (colon != arg) { *colon = '\0'; - if (inet_aton(arg, &ina) == 0) { + if (inet_pton(AF_INET, arg, &ina) != 1) { if ((hp = gethostbyname(arg)) == NULL) { option_error("unknown host: %s", arg); return -1; @@ -1589,7 +1591,7 @@ setipaddr(char *arg) * If colon last character, then no remote addr. */ if (*++colon != '\0') { - if (inet_aton(colon, &ina) == 0) { + if (inet_pton(AF_INET, colon, &ina) != 1) { if ((hp = gethostbyname(colon)) == NULL) { option_error("unknown host: %s", colon); return -1; @@ -1653,7 +1655,7 @@ setnetmask(char **argv) { struct in_addr ina; - if (inet_aton(*argv, &ina) == 0 || (netmask & ~ina.s_addr) != 0) { + if (inet_pton(AF_INET, *argv, &ina) != 1 || (netmask & ~ina.s_addr) != 0) { option_error("invalid netmask value '%s'", *argv); return (0); } @@ -2112,7 +2114,7 @@ setdnsaddr(char **argv) struct in_addr ina; struct hostent *hp; - if (inet_aton(*argv, &ina) == 0) { + if (inet_pton(AF_INET, *argv, &ina) != 1) { if ((hp = gethostbyname(*argv)) == NULL) { option_error("invalid address parameter '%s' for ms-dns option", *argv); @@ -2142,7 +2144,7 @@ setwinsaddr(char **argv) struct in_addr ina; struct hostent *hp; - if (inet_aton(*argv, &ina) == 0) { + if (inet_pton(AF_INET, *argv, &ina) != 1) { if ((hp = gethostbyname(*argv)) == NULL) { option_error("invalid address parameter '%s' for ms-wins option", *argv); -- 2.20.1