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: 22045 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;