Page MenuHomeFreeBSD

D37139.diff
No OneTemporary

D37139.diff

diff --git a/include/netdb.h b/include/netdb.h
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -161,8 +161,8 @@
/*
* Error return codes from gai_strerror(3), see RFC 3493.
*/
-#if 0
-/* Obsoleted on RFC 3493 */
+#if __BSD_VISIBLE /* not in POSIX */
+/* EAI_ADDRFAMILY was obsoleted by RFC 3493, used as extension */
#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
#endif
#define EAI_AGAIN 2 /* name could not be resolved at this time */
@@ -170,17 +170,20 @@
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
#define EAI_FAMILY 5 /* address family not recognized */
#define EAI_MEMORY 6 /* memory allocation failure */
-#if 0
-/* Obsoleted on RFC 3493 */
+#if __BSD_VISIBLE /* not in POSIX */
+/* EAI_NODATA was obsoleted by RFC 3493, retained here as extension */
#define EAI_NODATA 7 /* no address associated with hostname */
#endif
#define EAI_NONAME 8 /* name does not resolve */
#define EAI_SERVICE 9 /* service not recognized for socket type */
#define EAI_SOCKTYPE 10 /* intended socket type was not recognized */
#define EAI_SYSTEM 11 /* system error returned in errno */
+#if __BSD_VISIBLE /* not in POSIX */
+/* The following 3 are not in RFC 3493 or POSIX, retained for compatibility */
#define EAI_BADHINTS 12 /* invalid value for hints */
#define EAI_PROTOCOL 13 /* resolved protocol is unknown */
#define EAI_OVERFLOW 14 /* argument buffer overflow */
+#endif
#define EAI_MAX 15
/*
diff --git a/include/nsswitch.h b/include/nsswitch.h
--- a/include/nsswitch.h
+++ b/include/nsswitch.h
@@ -53,6 +53,7 @@
#define NS_NOTFOUND (1<<2) /* source responded 'no such entry' */
#define NS_TRYAGAIN (1<<3) /* source busy, may respond to retry */
#define NS_RETURN (1<<4) /* stop search, e.g. for ERANGE */
+#define NS_ADDRFAMILY (1<<5) /* no addr for fam, getaddrinfo only */
#define NS_TERMINATE (NS_SUCCESS|NS_RETURN) /* flags that end search */
#define NS_STATUSMASK 0x000000ff /* bitmask to get the status flags */
diff --git a/lib/libc/net/gai_strerror.3 b/lib/libc/net/gai_strerror.3
--- a/lib/libc/net/gai_strerror.3
+++ b/lib/libc/net/gai_strerror.3
@@ -18,7 +18,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 23, 2018
+.Dd November 1, 2022
.Dt GAI_STRERROR 3
.Os
.Sh NAME
@@ -42,7 +42,9 @@
The following error codes and their meaning are defined in
.In netdb.h :
.Pp
-.Bl -tag -width ".Dv EAI_BADFLAGS" -offset indent -compact
+.Bl -tag -width ".Dv EAI_ADDRFAMILY" -offset indent -compact
+.It Dv EAI_ADDRFAMILY
+Address family for hostname not supported
.It Dv EAI_AGAIN
Name could not be resolved at this time
.It Dv EAI_BADFLAGS
@@ -56,6 +58,8 @@
Address family was not recognized
.It Dv EAI_MEMORY
Memory allocation failure
+.It Dv EAI_NODATA
+No address associated with hostname
.It Dv EAI_NONAME
Name does not resolve
.It Dv EAI_OVERFLOW
@@ -83,7 +87,14 @@
.Xr getaddrinfo 3 ,
.Xr getnameinfo 3
.Sh STANDARDS
-.Bl -tag -width ".It RFC 2743"
+.Bl -tag -width ".It RFC 3493"
.It RFC 3493
Basic Socket Interface Extensions for IPv6
.El
+.Pp
+EAI_ADDRFAMILY and EAI_NODATA were in previous RFCs, but not in RFC 3493.
+They are not in POSIX (IEEE Std 1003.1-2017).
+They were in
+.Fx
+before 5.2, and were re-added for 14.0.
+EAI_BADHINTS, EAI_OVERFLOW, and EAI_PROTOCOL are not in RFC 3493 or POSIX.
diff --git a/lib/libc/net/gai_strerror.c b/lib/libc/net/gai_strerror.c
--- a/lib/libc/net/gai_strerror.c
+++ b/lib/libc/net/gai_strerror.c
@@ -44,17 +44,19 @@
#endif
#include "un-namespace.h"
-/* Entries EAI_ADDRFAMILY (1) and EAI_NODATA (7) are obsoleted, but left */
-/* for backwards compatibility with userland code prior to RFC2553bis-02 */
+/*
+ * Entries EAI_ADDRFAMILY (1) and EAI_NODATA (7) were omitted from RFC 3493,
+ * but are or may be used as extensions or in old code.
+ */
static const char *ai_errlist[] = {
"Success", /* 0 */
- "Address family for hostname not supported", /* 1: Obsolete */
+ "Address family for hostname not supported", /* EAI_ADDRFAMILY */
"Name could not be resolved at this time", /* EAI_AGAIN */
"Flags parameter had an invalid value", /* EAI_BADFLAGS */
"Non-recoverable failure in name resolution", /* EAI_FAIL */
"Address family not recognized", /* EAI_FAMILY */
"Memory allocation failure", /* EAI_MEMORY */
- "No address associated with hostname", /* 7: Obsolete*/
+ "No address associated with hostname", /* EAI_NODATA*/
"Name does not resolve", /* EAI_NONAME */
"Service was not recognized for socket type", /* EAI_SERVICE */
"Intended socket type was not recognized", /* EAI_SOCKTYPE */
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -1953,6 +1953,9 @@
case NS_NOTFOUND:
error = EAI_NONAME;
goto free;
+ case NS_ADDRFAMILY:
+ error = EAI_ADDRFAMILY;
+ goto free;
case NS_SUCCESS:
error = 0;
for (cur = result; cur; cur = cur->ai_next) {
@@ -2341,7 +2344,9 @@
if (res_searchN(hostname, &q, res) < 0) {
free(buf);
free(buf2);
- return NS_NOTFOUND;
+ if (res->res_h_errno == NO_DATA)
+ return (NS_ADDRFAMILY);
+ return (NS_NOTFOUND);
}
/* prefer IPv6 */
if (q.next) {
@@ -2363,15 +2368,16 @@
if (sentinel.ai_next == NULL)
switch (res->res_h_errno) {
case HOST_NOT_FOUND:
+ return (NS_NOTFOUND);
case NO_DATA:
- return NS_NOTFOUND;
+ return (NS_ADDRFAMILY);
case TRY_AGAIN:
- return NS_TRYAGAIN;
+ return (NS_TRYAGAIN);
default:
- return NS_UNAVAIL;
+ return (NS_UNAVAIL);
}
*((struct addrinfo **)rv) = sentinel.ai_next;
- return NS_SUCCESS;
+ return (NS_SUCCESS);
}
static void
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -67,12 +67,15 @@
* Error messages for resolver errors
*/
static struct fetcherr netdb_errlist[] = {
+#ifdef EAI_ADDRFAMILY
+ { EAI_ADDRFAMILY, FETCH_RESOLV, "Address family for host not supported" },
+#endif
#ifdef EAI_NODATA
- { EAI_NODATA, FETCH_RESOLV, "Host not found" },
+ { EAI_NODATA, FETCH_RESOLV, "No address for host" },
#endif
{ EAI_AGAIN, FETCH_TEMP, "Transient resolver failure" },
{ EAI_FAIL, FETCH_RESOLV, "Non-recoverable resolver failure" },
- { EAI_NONAME, FETCH_RESOLV, "No address record" },
+ { EAI_NONAME, FETCH_RESOLV, "Host does not resolve" },
{ -1, FETCH_UNKNOWN, "Unknown resolver error" }
};

File Metadata

Mime Type
text/plain
Expires
Sun, Jan 12, 11:31 PM (21 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15773809
Default Alt Text
D37139.diff (6 KB)

Event Timeline