From 262a2674c1e93c642b8a091beda418ca1ffa847b Mon Sep 17 00:00:00 2001 From: florian Date: Thu, 22 Aug 2024 07:56:47 +0000 Subject: [PATCH] Mechanically change inet_aton to inet_pton. npppd does not document that it would accept truncated or otherwise not fully spelled out IPv4 addresses. ok yasuoka --- usr.sbin/npppd/common/addr_range.c | 13 +++++++------ usr.sbin/npppd/npppd/npppd_subr.c | 4 ++-- usr.sbin/npppd/npppd/parse.y | 4 ++-- usr.sbin/npppd/npppd/privsep.c | 6 +++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/usr.sbin/npppd/common/addr_range.c b/usr.sbin/npppd/common/addr_range.c index d81e4b318f1..4f8897268b4 100644 --- a/usr.sbin/npppd/common/addr_range.c +++ b/usr.sbin/npppd/common/addr_range.c @@ -1,4 +1,4 @@ -/* $OpenBSD: addr_range.c,v 1.7 2024/02/26 08:25:51 yasuoka Exp $ */ +/* $OpenBSD: addr_range.c,v 1.8 2024/08/22 07:56:47 florian Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. * All rights reserved. @@ -56,13 +56,14 @@ * Author: * Yasuoka Masahiko * - * $Id: addr_range.c,v 1.7 2024/02/26 08:25:51 yasuoka Exp $ + * $Id: addr_range.c,v 1.8 2024/08/22 07:56:47 florian Exp $ */ #ifdef ADDR_RANGE_DEBUG #define IIJDEBUG #endif #include +#include #include #include @@ -264,23 +265,23 @@ in_addr_range_list_add(struct in_addr_range **list, const char *str) is_maskaddr = 1; } - if (inet_aton(p0, &a0) != 1) { + if (inet_pton(AF_INET, p0, &a0) != 1) { if (errno == 0) errno = EINVAL; #ifdef IIJDEBUG saved_errno = errno; - log_printf(LOG_DL_1, "inet_aton(%s) failed: %m", p0); + log_printf(LOG_DL_1, "inet_pton(%s) failed: %m", p0); errno = saved_errno; #endif free(p0); return -1; } - if ((is_range || is_maskaddr) && inet_aton(p1, &a1) != 1) { + if ((is_range || is_maskaddr) && inet_pton(AF_INET, p1, &a1) != 1) { if (errno == 0) errno = EINVAL; #ifdef IIJDEBUG saved_errno = errno; - log_printf(LOG_DL_1, "inet_aton(%s) failed: %m", p1); + log_printf(LOG_DL_1, "inet_pton(%s) failed: %m", p1); errno = saved_errno; #endif free(p0); diff --git a/usr.sbin/npppd/npppd/npppd_subr.c b/usr.sbin/npppd/npppd/npppd_subr.c index e24789b3495..7096ebb26f5 100644 --- a/usr.sbin/npppd/npppd/npppd_subr.c +++ b/usr.sbin/npppd/npppd/npppd_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: npppd_subr.c,v 1.21 2021/03/29 03:54:39 yasuoka Exp $ */ +/* $OpenBSD: npppd_subr.c,v 1.22 2024/08/22 07:56:47 florian Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -108,7 +108,7 @@ load_resolv_conf(struct in_addr *pri, struct in_addr *sec) addr = pri; else addr = sec; - if (inet_aton(ap, addr) != 1) { + if (inet_pton(AF_INET, ap, addr) != 1) { /* * FIXME: If configured IPv6, it may have IPv6 * FIXME: address. For the present, continue. diff --git a/usr.sbin/npppd/npppd/parse.y b/usr.sbin/npppd/npppd/parse.y index fd8bb0d2956..4c1c894ce84 100644 --- a/usr.sbin/npppd/npppd/parse.y +++ b/usr.sbin/npppd/npppd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.30 2024/07/17 08:26:19 yasuoka Exp $ */ +/* $OpenBSD: parse.y,v 1.31 2024/08/22 07:56:47 florian Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -639,7 +639,7 @@ addressport : address optport { ; in4_addr : STRING { - if (inet_aton($1, &($$)) != 1) { + if (inet_pton(AF_INET, $1, &($$)) != 1) { yyerror("could not parse the address %s", $1); free($1); YYERROR; diff --git a/usr.sbin/npppd/npppd/privsep.c b/usr.sbin/npppd/npppd/privsep.c index 6736a9779d7..43ec8a4ce7e 100644 --- a/usr.sbin/npppd/npppd/privsep.c +++ b/usr.sbin/npppd/npppd/privsep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: privsep.c,v 1.25 2024/01/18 09:58:23 claudio Exp $ */ +/* $OpenBSD: privsep.c,v 1.26 2024/08/22 07:56:47 florian Exp $ */ /* * Copyright (c) 2010 Yasuoka Masahiko @@ -708,7 +708,7 @@ privsep_priv_dispatch_imsg(struct imsgbuf *ibuf) } if ((retval = cgetstr(buf, "framed-ip-address", &str)) >= 0) { - if (inet_aton(str, + if (inet_pton(AF_INET, str, &r.framed_ip_address) != 1) goto on_broken_entry; free(str); @@ -717,7 +717,7 @@ privsep_priv_dispatch_imsg(struct imsgbuf *ibuf) if ((retval = cgetstr(buf, "framed-ip-netmask", &str)) >= 0) { - if (inet_aton(str, + if (inet_pton(AF_INET, str, &r.framed_ip_netmask) != 1) goto on_broken_entry; free(str); -- 2.20.1