Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANs4VLxjt0bpn4ENkkVQerfML7y=BY4xT1UA=a3yxah8mm9iuA@mail.gmail.com>
Date: Sun, 10 Jul 2022 16:32:51 +0200
From: Tomasz Duda <tomaszduda23@...il.com>
To: musl@...ts.openwall.com
Subject: AF_LOCAL

Hi,

I'm using
python:3.9-alpine3.14
It looks that AF_LOCAL is not implemented.
It would be nice if you could include it.

BR,
TD

diff --git a/src/network/getnameinfo.c b/src/network/getnameinfo.c
index 949e181..7d3a9c3 100644
--- a/src/network/getnameinfo.c
+++ b/src/network/getnameinfo.c
@@ -11,7 +11,9 @@
#include <resolv.h>
#include "lookup.h"
#include "stdio_impl.h"
+#include <sys/un.h>
+#define MIN(a,b) ((a)<(b) ? (a) : (b))
#define PTR_MAX (64 + sizeof ".in-addr.arpa")
#define RR_PTR 12
@@ -118,6 +120,29 @@ static int dns_parse_callback(void *c, int rr, const
void *data, int len, const
}
+/*
+ * getnameinfo_local():
+ * Format an local address into a printable format.
+ */
+/* ARGSUSED */
+static int
+getnameinfo_local(const struct sockaddr *sa, socklen_t salen,
+ char *host, socklen_t hostlen, char *serv, socklen_t servlen,
+ int flags __attribute__((unused)))
+{
+ const struct sockaddr_un *sun =
+ (const struct sockaddr_un *)(const void *)sa;
+ if (salen < (socklen_t) offsetof(struct sockaddr_un, sun_path)) {
+ return EAI_FAMILY;
+ }
+ if (serv != NULL && servlen > 0)
+ serv[0] = '\0';
+ if (host && hostlen > 0)
+ strncpy(host, sun->sun_path,
+ MIN((socklen_t) sizeof(sun->sun_path) + 1, hostlen));
+ return 0;
+}
+
int getnameinfo(const struct sockaddr *restrict sa, socklen_t sl,
char *restrict node, socklen_t nodelen,
char *restrict serv, socklen_t servlen,
@@ -145,6 +170,8 @@ int getnameinfo(const struct sockaddr *restrict sa,
socklen_t sl,
mkptr4(ptr, a+12);
scopeid = ((struct sockaddr_in6 *)sa)->sin6_scope_id;
break;
+ case AF_LOCAL:
+ return getnameinfo_local(sa, sl, node, nodelen, serv, servlen, flags);
default:
return EAI_FAMILY;
}

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.