Skip to content

Commit b5d570e

Browse files
committed
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
1 parent afbdcd4 commit b5d570e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/libfetch/common.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,12 @@ fetch_connect(const char *host, int port, int af, int verbose)
637637
/* try each server address in turn */
638638
for (err = 0, sai = sais; sai != NULL; sai = sai->ai_next) {
639639
/* open socket */
640-
if ((sd = socket(sai->ai_family, SOCK_STREAM, 0)) < 0)
640+
if ((sd = socket(sai->ai_family, SOCK_STREAM, 0)) < 0) {
641+
err = -1;
642+
if (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT)
643+
continue;
641644
goto syserr;
645+
}
642646
/* attempt to bind to client address */
643647
for (err = 0, cai = cais; cai != NULL; cai = cai->ai_next) {
644648
if (cai->ai_family != sai->ai_family)

0 commit comments

Comments
 (0)