Mechanically change inet_aton to inet_pton.
authorflorian <florian@openbsd.org>
Thu, 22 Aug 2024 07:56:47 +0000 (07:56 +0000)
committerflorian <florian@openbsd.org>
Thu, 22 Aug 2024 07:56:47 +0000 (07:56 +0000)
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
usr.sbin/npppd/npppd/npppd_subr.c
usr.sbin/npppd/npppd/parse.y
usr.sbin/npppd/npppd/privsep.c

index d81e4b3..4f88972 100644 (file)
@@ -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.
  * Author:
  *     Yasuoka Masahiko <yasuoka@iij.ad.jp>
  *
- * $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 <sys/types.h>
+#include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
@@ -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);
index e24789b..7096ebb 100644 (file)
@@ -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.
index fd8bb0d..4c1c894 100644 (file)
@@ -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 <henning@openbsd.org>
@@ -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;
index 6736a97..43ec8a4 100644 (file)
@@ -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 <yasuoka@openbsd.org>
@@ -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);