summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2024-08-21 14:57:06 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2024-08-21 14:57:06 +0000
commit7dab37ddd14639938001e51bb0217d1eb78f66bf (patch)
tree783d19a2ae1ea8eb05821bcb351a1686f86360e8
parent895578359db71c118988644d15205f47f1a4fc63 (diff)
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
-rw-r--r--usr.sbin/pppd/auth.c8
-rw-r--r--usr.sbin/pppd/options.c18
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 <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+
#include <ctype.h>
#include <stdio.h>
#include <errno.h>
@@ -53,8 +57,6 @@
#include <string.h>
#include <netdb.h>
#include <pwd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#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);