From patchwork Fri Jun 13 15:32:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 359558 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 58B5B14008B for ; Sat, 14 Jun 2014 01:32:36 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=wsDzbOaRa/oMeA/SNssB+5ZGQ5ktwm8 O+Z+4ONC2aO+pP4jMmcUpJUU4+t+xhCfC/0PHG+Zu2CVArS8fSb1JsghQu4hvhKw oyPiI9S1L7zUmMlWjH+rMsFr9cnc2y/wTsEzJYF4tfvfuCHycxInJsnMvKPPLktV VVhwAn2G0PAU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=YIUi53x4j+I4YuYzXYOCrpzriFM=; b=oAJN5 t8svrpQ0GLGsmabxwMPXRrJZJoeSBtq/7J5kQg782Shanc0Wk+1XDZikrkoMXvFG ir/S169Z8UBKOfscQe1SYwtwOeDAmHmANReHiTU1MT56X7qpIrqbZBXgk3NY8UVw lJ6X1Zz/L4T1GhN1RopoRqT2QdyXIxLSPwReXI= Received: (qmail 2465 invoked by alias); 13 Jun 2014 15:32:21 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 2439 invoked by uid 89); 13 Jun 2014 15:32:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: hall.aurel32.net From: Aurelien Jarno To: libc-alpha@sourceware.org Cc: Aurelien Jarno Subject: [PATCH 2/4] resolv: fix nsaddr_list array indexing Date: Fri, 13 Jun 2014 17:32:11 +0200 Message-Id: <1402673533-13243-3-git-send-email-aurelien@aurel32.net> In-Reply-To: <1402673533-13243-1-git-send-email-aurelien@aurel32.net> References: <1402673533-13243-1-git-send-email-aurelien@aurel32.net> This commit is basically a revert of commits 6f5c3117 and 16b7dc27. Those commits changed the indexing of nsaddr_list array when reading resolv.conf, with the goal to simplify the mapping between the nsaddr_list and nsaddrs, by making sure we don't have any name server at the same both arrays. However the code in __libc_res_nsend hasn't been updated, and still assume that all nsaddr_list entries are located at the beginning of the array, without any gap. This causes some issues when IPv6 name servers are in use. 2014-06-13 Aurelien Jarno [BZ #17053] * resolv/res_init.c (__res_vinit): Fill in IPv4 name server information using the nserv index. Only count IPv4 name servers in statp->nscount. diff --git a/resolv/res_init.c b/resolv/res_init.c index bdec4d9..37004ab 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -308,9 +308,9 @@ __res_vinit(res_state statp, int preinit) { cp++; if ((*cp != '\0') && (*cp != '\n') && __inet_aton(cp, &a)) { - statp->nsaddr_list[nservall].sin_addr = a; - statp->nsaddr_list[nservall].sin_family = AF_INET; - statp->nsaddr_list[nservall].sin_port = + statp->nsaddr_list[nserv].sin_addr = a; + statp->nsaddr_list[nserv].sin_family = AF_INET; + statp->nsaddr_list[nserv].sin_port = htons(NAMESERVER_PORT); nserv++; #ifdef _LIBC @@ -414,7 +414,7 @@ __res_vinit(res_state statp, int preinit) { continue; } } - statp->nscount = nservall; + statp->nscount = nserv; #ifdef _LIBC if (nservall - nserv > 0) { statp->_u._ext.nscount6 = nservall - nserv;