diff options
| author | Dag-Erling Smørgrav <des@FreeBSD.org> | 2026-02-21 01:18:18 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2026-02-26 04:03:43 +0000 |
| commit | 31f3640c4aa859f2e3a78a51f3c43e0e6e7239f9 (patch) | |
| tree | bc2dfbdf52a912239e7a0bf84fa65fb0774504d4 | |
| parent | cca6f5eadb796b03379eb21f38c74ca46a64e45b (diff) | |
libfetch: Gracefully skip unsupported protocols
If socket() fails because the address family or protocol is unsupported,
just continue with the next address.
MFC after: 1 week
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D55407
(cherry picked from commit b5d570e711da1dad303312bebaf1bd2fb720f0dc)
| -rw-r--r-- | lib/libfetch/common.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c index 784da2d9e6a2..5115933b8e41 100644 --- a/lib/libfetch/common.c +++ b/lib/libfetch/common.c @@ -638,8 +638,12 @@ fetch_connect(const char *host, int port, int af, int verbose) /* try each server address in turn */ for (err = 0, sai = sais; sai != NULL; sai = sai->ai_next) { /* open socket */ - if ((sd = socket(sai->ai_family, SOCK_STREAM, 0)) < 0) + if ((sd = socket(sai->ai_family, SOCK_STREAM, 0)) < 0) { + err = -1; + if (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT) + continue; goto syserr; + } /* attempt to bind to client address */ for (err = 0, cai = cais; cai != NULL; cai = cai->ai_next) { if (cai->ai_family != sai->ai_family) |
