From patchwork Fri Jun 2 14:37:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 770390 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 3wfRcx2C6Fz9s03 for ; Sat, 3 Jun 2017 00:37:21 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="xdJ3GljW"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:cc:references:from:message-id:date :mime-version:in-reply-to:content-type; q=dns; s=default; b=DHVT 79mVF/OV/5ZzovQwcdEc+1MOFiGJFszxwxYsfS5hsgWnoAiPVbvdzQ1sz/3DEPMU jlZmS02+6oXMg47mbZf8hc5b0tlY/3Corq1xNmXrZYkXM9QW9mzl/NmYBJktBN3C uDIqa7mYZEpTZhnJruzfC6w5v0XNTn1p68fbl4Y= 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:subject:to:cc:references:from:message-id:date :mime-version:in-reply-to:content-type; s=default; bh=Z2gkzXaUEZ +0nH2TMb32vpoOv84=; b=xdJ3GljWqIb3fxRKTB1ckDM2DuUh/VxDCPunI4EYKo fGm2ZaAP2pCoRpmlVis2ibj33ercl354msbhoSH13K32xBnzGNObpNyLR9yU6kOt JW+bSobHYoOW5SjcbsyrwUdo+NLTJh8pMdFLaGqNntVRwVf49A+pT9zac83BXmFl g= Received: (qmail 46399 invoked by alias); 2 Jun 2017 14:37:10 -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 46381 invoked by uid 89); 2 Jun 2017 14:37:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=spotted X-HELO: mx1.redhat.com DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 6AC7991FD5 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=fweimer@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 6AC7991FD5 Subject: Re: [PATCH] getaddrinfo: Always allocate canonical name on the heap To: Adhemerval Zanella Cc: libc-alpha@sourceware.org References: <20170511100718.1F66A401E714A@oldenburg.str.redhat.com> <52802461-8188-52e7-eeba-9cdce0be340d@linaro.org> <2738bd73-a636-1e6e-7eb0-225c99d91b5d@redhat.com> From: Florian Weimer Message-ID: <7ba94b4d-c575-e122-17d0-8f00edfa21a6@redhat.com> Date: Fri, 2 Jun 2017 16:37:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: On 06/02/2017 04:10 PM, Adhemerval Zanella wrote: > I noticed on x86_64 (gcc 5.4), powerpc64le (gcc 5.4), aarch64 (gcc 4.9.2), > and sparc64 (gcc 6.3.1). My guess is newer GCC versions are inline it. Fair enough. What about the attached patch? I spotted one missing heap allocation (which is not visible as a bug because the code doesn't try to pass the pointer to free), and included that as well. Thanks, Florian getaddrinfo: Fix localplt failure involving strdup 2017-06-02 Florian Weimer * sysdeps/posix/getaddrinfo.c (gethosts): Eliminate another strdupa. (getcanonname): Use __strdup instead of strdup. diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index d92db70..a8b5bb5 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -286,9 +286,16 @@ convert_hostent_to_gaih_addrtuple (const struct addrinfo *req, } \ *pat = addrmem; \ \ - if (localcanon != NULL && canon == NULL) \ - canon = strdupa (localcanon); \ - \ + if (localcanon != NULL && canon == NULL) \ + { \ + canonbuf = __strdup (localcanon); \ + if (canonbuf == NULL) \ + { \ + result = -EAI_SYSTEM; \ + goto free_and_return; \ + } \ + canon = canonbuf; \ + } \ if (_family == AF_INET6 && *pat != NULL) \ got_ipv6 = true; \ } \ @@ -330,7 +337,7 @@ getcanonname (service_user *nip, struct gaih_addrtuple *at, const char *name) string. */ s = (char *) name; } - return strdup (name); + return __strdup (name); } static int