Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220826174834.GD1923@voyager>
Date: Fri, 26 Aug 2022 19:48:34 +0200
From: Markus Wichmann <nullplan@....net>
To: musl@...ts.openwall.com
Subject: Re: IPv4 fallback in __res_msend_rc not functional

On Fri, Aug 26, 2022 at 12:16:03PM -0400, Rich Felker wrote:
> How does this look for handling the cases with no (usable)
> nameservers?
>
> diff --git a/src/network/res_msend.c b/src/network/res_msend.c
> index 105bf598..1e5f3516 100644
> --- a/src/network/res_msend.c
> +++ b/src/network/res_msend.c
> @@ -47,6 +47,11 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries,
>  	struct pollfd pfd;
>  	unsigned long t0, t1, t2;
>
> +	if (!conf->nns) {
> +		errno = ENOENT;
> +		return -1;
> +	}
> +
>  	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
>
>  	timeout = 1000*conf->timeout;
> @@ -72,6 +77,11 @@ int __res_msend_rc(int nqueries, const unsigned char *const *queries,
>
>  	/* Handle case where system lacks IPv6 support */
>  	if (fd < 0 && family == AF_INET6 && errno == EAFNOSUPPORT) {
> +		for (i=0; i<nns && conf->ns[nns].family == AF_INET6; i++);
> +		if (i==nns) {
> +			pthread_setcancelstate(cs, 0);
> +			return -1;
> +		}
>  		fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
>  		family = AF_INET;
>  		sl = sizeof sa.sin;
>
> __res_msend returning -1 will cause getaddrinfo to fail with
> EAI_SYSTEM, in which case the caller can find the reason in errno.
>
> Rich

Seems like it would solve the problem. Except for the thing you already
mentioned.

Ciao,
Markus

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.