2022-06-05 01:05:04 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2022-05-17 16:55:36 +00:00
|
|
|
From: Luke <luke.wilde@live.co.uk>
|
|
|
|
Date: Sat, 30 Apr 2022 10:58:10 +0000
|
2022-06-05 01:05:04 +00:00
|
|
|
Subject: [PATCH] Remove inet_aton() redefinition
|
2022-05-17 16:55:36 +00:00
|
|
|
|
|
|
|
Co-Authored-By: Patrick Meyer <git@the-space.agency>
|
|
|
|
---
|
|
|
|
openbsd-compat/inet_aton.c | 172 ++++++++++++++++----------------
|
|
|
|
openbsd-compat/openbsd-compat.h | 2 +-
|
|
|
|
2 files changed, 87 insertions(+), 87 deletions(-)
|
|
|
|
|
2020-09-26 15:12:27 +00:00
|
|
|
diff --git a/openbsd-compat/inet_aton.c b/openbsd-compat/inet_aton.c
|
2022-04-30 10:58:10 +00:00
|
|
|
index 5efcc5f..14aa47b 100644
|
2020-09-26 15:12:27 +00:00
|
|
|
--- a/openbsd-compat/inet_aton.c
|
|
|
|
+++ b/openbsd-compat/inet_aton.c
|
|
|
|
@@ -53,7 +53,7 @@
|
|
|
|
|
|
|
|
#include "includes.h"
|
|
|
|
|
|
|
|
-#if !defined(HAVE_INET_ATON)
|
|
|
|
+#if !defined(__serenity__)
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
2022-04-30 10:58:10 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
@@ -83,96 +83,96 @@ inet_addr(const char *cp)
|
2020-09-26 15:12:27 +00:00
|
|
|
* This replaces inet_addr, the return value from which
|
|
|
|
* cannot distinguish between failure and a local broadcast address.
|
|
|
|
*/
|
|
|
|
-int
|
|
|
|
-inet_aton(const char *cp, struct in_addr *addr)
|
|
|
|
-{
|
|
|
|
- u_int32_t val;
|
|
|
|
- int base, n;
|
|
|
|
- char c;
|
|
|
|
- u_int parts[4];
|
|
|
|
- u_int *pp = parts;
|
|
|
|
+// int
|
|
|
|
+// inet_aton(const char *cp, struct in_addr *addr)
|
|
|
|
+// {
|
|
|
|
+// u_int32_t val;
|
|
|
|
+// int base, n;
|
|
|
|
+// char c;
|
|
|
|
+// u_int parts[4];
|
|
|
|
+// u_int *pp = parts;
|
|
|
|
|
|
|
|
- c = *cp;
|
|
|
|
- for (;;) {
|
|
|
|
- /*
|
|
|
|
- * Collect number up to ``.''.
|
|
|
|
- * Values are specified as for C:
|
|
|
|
- * 0x=hex, 0=octal, isdigit=decimal.
|
|
|
|
- */
|
|
|
|
- if (!isdigit(c))
|
|
|
|
- return (0);
|
|
|
|
- val = 0; base = 10;
|
|
|
|
- if (c == '0') {
|
|
|
|
- c = *++cp;
|
|
|
|
- if (c == 'x' || c == 'X')
|
|
|
|
- base = 16, c = *++cp;
|
|
|
|
- else
|
|
|
|
- base = 8;
|
|
|
|
- }
|
|
|
|
- for (;;) {
|
|
|
|
- if (isascii(c) && isdigit(c)) {
|
|
|
|
- val = (val * base) + (c - '0');
|
|
|
|
- c = *++cp;
|
|
|
|
- } else if (base == 16 && isascii(c) && isxdigit(c)) {
|
|
|
|
- val = (val << 4) |
|
|
|
|
- (c + 10 - (islower(c) ? 'a' : 'A'));
|
|
|
|
- c = *++cp;
|
|
|
|
- } else
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if (c == '.') {
|
|
|
|
- /*
|
|
|
|
- * Internet format:
|
|
|
|
- * a.b.c.d
|
|
|
|
- * a.b.c (with c treated as 16 bits)
|
|
|
|
- * a.b (with b treated as 24 bits)
|
|
|
|
- */
|
|
|
|
- if (pp >= parts + 3)
|
|
|
|
- return (0);
|
|
|
|
- *pp++ = val;
|
|
|
|
- c = *++cp;
|
|
|
|
- } else
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- /*
|
|
|
|
- * Check for trailing characters.
|
|
|
|
- */
|
|
|
|
- if (c != '\0' && (!isascii(c) || !isspace(c)))
|
|
|
|
- return (0);
|
|
|
|
- /*
|
|
|
|
- * Concoct the address according to
|
|
|
|
- * the number of parts specified.
|
|
|
|
- */
|
|
|
|
- n = pp - parts + 1;
|
|
|
|
- switch (n) {
|
|
|
|
+// c = *cp;
|
|
|
|
+// for (;;) {
|
|
|
|
+// /*
|
|
|
|
+// * Collect number up to ``.''.
|
|
|
|
+// * Values are specified as for C:
|
|
|
|
+// * 0x=hex, 0=octal, isdigit=decimal.
|
|
|
|
+// */
|
|
|
|
+// if (!isdigit(c))
|
|
|
|
+// return (0);
|
|
|
|
+// val = 0; base = 10;
|
|
|
|
+// if (c == '0') {
|
|
|
|
+// c = *++cp;
|
|
|
|
+// if (c == 'x' || c == 'X')
|
|
|
|
+// base = 16, c = *++cp;
|
|
|
|
+// else
|
|
|
|
+// base = 8;
|
|
|
|
+// }
|
|
|
|
+// for (;;) {
|
|
|
|
+// if (isascii(c) && isdigit(c)) {
|
|
|
|
+// val = (val * base) + (c - '0');
|
|
|
|
+// c = *++cp;
|
|
|
|
+// } else if (base == 16 && isascii(c) && isxdigit(c)) {
|
|
|
|
+// val = (val << 4) |
|
|
|
|
+// (c + 10 - (islower(c) ? 'a' : 'A'));
|
|
|
|
+// c = *++cp;
|
|
|
|
+// } else
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
|
|
+// if (c == '.') {
|
|
|
|
+// /*
|
|
|
|
+// * Internet format:
|
|
|
|
+// * a.b.c.d
|
|
|
|
+// * a.b.c (with c treated as 16 bits)
|
|
|
|
+// * a.b (with b treated as 24 bits)
|
|
|
|
+// */
|
|
|
|
+// if (pp >= parts + 3)
|
|
|
|
+// return (0);
|
|
|
|
+// *pp++ = val;
|
|
|
|
+// c = *++cp;
|
|
|
|
+// } else
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
|
|
+// /*
|
|
|
|
+// * Check for trailing characters.
|
|
|
|
+// */
|
|
|
|
+// if (c != '\0' && (!isascii(c) || !isspace(c)))
|
|
|
|
+// return (0);
|
|
|
|
+// /*
|
|
|
|
+// * Concoct the address according to
|
|
|
|
+// * the number of parts specified.
|
|
|
|
+// */
|
|
|
|
+// n = pp - parts + 1;
|
|
|
|
+// switch (n) {
|
|
|
|
|
|
|
|
- case 0:
|
|
|
|
- return (0); /* initial nondigit */
|
|
|
|
+// case 0:
|
|
|
|
+// return (0); /* initial nondigit */
|
|
|
|
|
|
|
|
- case 1: /* a -- 32 bits */
|
|
|
|
- break;
|
|
|
|
+// case 1: /* a -- 32 bits */
|
|
|
|
+// break;
|
|
|
|
|
|
|
|
- case 2: /* a.b -- 8.24 bits */
|
|
|
|
- if ((val > 0xffffff) || (parts[0] > 0xff))
|
|
|
|
- return (0);
|
|
|
|
- val |= parts[0] << 24;
|
|
|
|
- break;
|
|
|
|
+// case 2: /* a.b -- 8.24 bits */
|
|
|
|
+// if ((val > 0xffffff) || (parts[0] > 0xff))
|
|
|
|
+// return (0);
|
|
|
|
+// val |= parts[0] << 24;
|
|
|
|
+// break;
|
|
|
|
|
|
|
|
- case 3: /* a.b.c -- 8.8.16 bits */
|
|
|
|
- if ((val > 0xffff) || (parts[0] > 0xff) || (parts[1] > 0xff))
|
|
|
|
- return (0);
|
|
|
|
- val |= (parts[0] << 24) | (parts[1] << 16);
|
|
|
|
- break;
|
|
|
|
+// case 3: /* a.b.c -- 8.8.16 bits */
|
|
|
|
+// if ((val > 0xffff) || (parts[0] > 0xff) || (parts[1] > 0xff))
|
|
|
|
+// return (0);
|
|
|
|
+// val |= (parts[0] << 24) | (parts[1] << 16);
|
|
|
|
+// break;
|
|
|
|
|
|
|
|
- case 4: /* a.b.c.d -- 8.8.8.8 bits */
|
|
|
|
- if ((val > 0xff) || (parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xff))
|
|
|
|
- return (0);
|
|
|
|
- val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if (addr)
|
|
|
|
- addr->s_addr = htonl(val);
|
|
|
|
- return (1);
|
|
|
|
-}
|
|
|
|
+// case 4: /* a.b.c.d -- 8.8.8.8 bits */
|
|
|
|
+// if ((val > 0xff) || (parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xff))
|
|
|
|
+// return (0);
|
|
|
|
+// val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
|
|
+// if (addr)
|
|
|
|
+// addr->s_addr = htonl(val);
|
|
|
|
+// return (1);
|
|
|
|
+// }
|
|
|
|
|
|
|
|
#endif /* !defined(HAVE_INET_ATON) */
|
|
|
|
diff --git a/openbsd-compat/openbsd-compat.h b/openbsd-compat/openbsd-compat.h
|
2022-04-30 10:58:10 +00:00
|
|
|
index 4316ab8..1c5c338 100644
|
2020-09-26 15:12:27 +00:00
|
|
|
--- a/openbsd-compat/openbsd-compat.h
|
|
|
|
+++ b/openbsd-compat/openbsd-compat.h
|
2022-04-30 10:58:10 +00:00
|
|
|
@@ -166,7 +166,7 @@ char *inet_ntoa(struct in_addr in);
|
2020-09-26 15:12:27 +00:00
|
|
|
const char *inet_ntop(int af, const void *src, char *dst, socklen_t size);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
-#ifndef HAVE_INET_ATON
|
|
|
|
+#if !defined(HAVE_INET_ATON) && !defined(__serenity__)
|
|
|
|
int inet_aton(const char *cp, struct in_addr *addr);
|
|
|
|
#endif
|
|
|
|
|