From patchwork Wed Aug 9 15:27:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 799830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-82948-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="YPmSg/wn"; dkim-atps=neutral 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 3xSFWg5tyWz9sN5 for ; Thu, 10 Aug 2017 01:27:43 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; q=dns; s=default; b= oex+bTa3YxWbqCapC1Yqzp48KToXH/gDAUmAgn7baH2ZKiMLdm3Iv+jw1dbieH5v IzZ/tMxGQFG8LQMqUIUEQ83T1Qz+S/IJsboYEeN3eUdMYH5vyDAmT6fe/+5HcPla vmeD6dccOEZpwD7WpquKgy7V0TJzKOdFKXXcnBx3LKk= 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:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; s=default; bh=xLWK9q gsMMHMPf2cFkJIBWwoMTs=; b=YPmSg/wnybz4TMX+dqktdRmXiM9dqPUXr6sps3 xBm+PDcATL9yjYoSA3JDnjIHrvcYdjgCC8RcwgbpdKmYr9vdWfvcTcAoMnGZERKf e7OwG1aanf9Wt606E+k9V/geK1vN3I5TyO9A7JlQ7LPMq79IhYXSRxhF/6bvzHRM LKUEU= Received: (qmail 54742 invoked by alias); 9 Aug 2017 15:27:24 -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 54612 invoked by uid 89); 9 Aug 2017 15:27:23 -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= X-HELO: mx1.redhat.com DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1C9FF25536C Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=fweimer@redhat.com Date: Wed, 09 Aug 2017 17:27:20 +0200 To: libc-alpha@sourceware.org Subject: [PATCH] nss: Keep thread-local h_errno in sync in get*_r functions User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20170809152720.3809C4029813A@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) 2017-08-09 Florian Weimer * nss/getXXbyYY_r.c (REENTRANT_NAME): Keep h_errno and *h_errnop in sync. diff --git a/nss/getXXbyYY_r.c b/nss/getXXbyYY_r.c index 6c547ea..5e3bead 100644 --- a/nss/getXXbyYY_r.c +++ b/nss/getXXbyYY_r.c @@ -219,6 +219,7 @@ INTERNAL (REENTRANT_NAME) (ADD_PARAMS, LOOKUP_TYPE *resbuf, char *buffer, if (res_ctx == NULL) { *h_errnop = NETDB_INTERNAL; + __set_h_errno (NETDB_INTERNAL); *result = NULL; return errno; } @@ -394,6 +395,12 @@ done: else if (status != NSS_STATUS_SUCCESS && !any_service) /* We were not able to use any service. */ *h_errnop = NO_RECOVERY; + + /* If an *_r function is called by an application, the h_errnop + parameter could be distinct from the h_errno variable. Keep both + in sync. This can result in a harmless self-assignment of the + h_errno variable. */ + __set_h_errno (*h_errnop); #endif #ifdef POSTPROCESS POSTPROCESS;