This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] nss: Keep thread-local h_errno in sync in get*_r functions


2017-08-09  Florian Weimer  <fweimer@redhat.com>

	* 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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]