From patchwork Mon Jun 19 12:26:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 21078 Received: (qmail 104424 invoked by alias); 19 Jun 2017 12:26:47 -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 104197 invoked by uid 89); 19 Jun 2017 12:26:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A3D5FCED9 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=fweimer@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A3D5FCED9 Date: Mon, 19 Jun 2017 14:26:47 +0200 To: libc-alpha@sourceware.org Subject: [PATCH COMMITTED] resolv: Introduce is_sort_mask and call it from res_vinit User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20170619122647.D703B40138EE9@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) 2017-06-19 Florian Weimer * resolv/res_init.c (sort_mask_chars, ISSORTMASK): Remove. (is_sort_mask): New function. (__res_vinit): Use it. diff --git a/resolv/res_init.c b/resolv/res_init.c index eb24fca..eb8e308 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -85,9 +85,6 @@ static void res_setoptions (res_state, const char *, const char *) internal_function; - -static const char sort_mask_chars[] = "/&"; -#define ISSORTMASK(ch) (strchr(sort_mask_chars, ch) != NULL) static u_int32_t net_mask (struct in_addr) __THROW; unsigned long long int __res_initstamp attribute_hidden; @@ -109,6 +106,14 @@ res_ninit(res_state statp) { } libc_hidden_def (__res_ninit) +/* Return true if CH separates the netmask in the "sortlist" + directive. */ +static inline bool +is_sort_mask (char ch) +{ + return ch == '/' || ch == '&'; +} + /* This function has to be reachable by res_data.c but not publically. */ int __res_vinit(res_state statp, int preinit) { @@ -305,14 +310,14 @@ __res_vinit(res_state statp, int preinit) { if (*cp == '\0' || *cp == '\n' || *cp == ';') break; net = cp; - while (*cp && !ISSORTMASK(*cp) && *cp != ';' && + while (*cp && !is_sort_mask (*cp) && *cp != ';' && isascii(*cp) && !isspace(*cp)) cp++; n = *cp; *cp = 0; if (__inet_aton(net, &a)) { statp->sort_list[nsort].addr = a; - if (ISSORTMASK(n)) { + if (is_sort_mask (n)) { *cp++ = n; net = cp; while (*cp && *cp != ';' &&