From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29082 invoked from network); 18 Jan 2023 15:27:04 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 18 Jan 2023 15:27:04 -0000 Received: (qmail 3811 invoked by uid 550); 18 Jan 2023 15:26:59 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 3772 invoked from network); 18 Jan 2023 15:26:58 -0000 Date: Wed, 18 Jan 2023 10:26:45 -0500 From: Rich Felker To: Barry Bond Cc: "musl@lists.openwall.com" Message-ID: <20230118152645.GG4163@brightrain.aerifal.cx> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Behavior change in getaddrbyname() with AF_UNSPEC On Sat, Jan 14, 2023 at 10:56:28PM +0000, Barry Bond wrote: > This is related to this change: https://git.musl-libc.org/cgit/musl/commit/?id=5cf1ac2443ad0dba263559a3fe043d929e0e5c4c made back in 2020. > > In the repro case, getaddrbyname() with AF_UNSPEC sends out two > requests, but only gets back a single response, with the ipv4 > address. There is no ipv6 on the network. > > name_from_dns() contains the relevant code. After __res_msend_rc() > returns, 'nq' is 2, and 'alens' is [96, 0], indicating that there > was an ipv4 response of 96 bytes, but no response for ipv6. Then the > validation code runs: > > for (i=0; i if (alens[i] < 4 || (abuf[i][3] & 15) == 2) return EAI_AGAIN; > if ((abuf[i][3] & 15) == 3) return 0; > if ((abuf[i][3] & 15) != 0) return EAI_FAIL; > } > > and the result is EAI_AGAIN, because alens[1]==0. > > Before this patch, the code would have parsed the ipv4 response via > __dns_parse(), failed to parse the empty second response because > alens[1]<12, and the function would return with ctx.cnt==1. That was the wrong behavior that this patch fixed. Previously, the query was timing out, but because there was an answer to the other query, we were erroneously hiding the failure from the application and presenting a timing-/network-congestion-dependent incorrect result (wrongly claiming only A or only AAAA exist when in fact we didn't get enough information to make that determination). "There is no ipv6 on the network" is not cause for the AAAA query to timeout. The ability to lookup a particular RR type has nothing to do with what network protocols are supported on your network. Can you describe the environment this is happening in and why it might be happening? Rich