summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2023-07-24 15:12:26 +0200
committerFlorian Weimer <fweimer@redhat.com>2023-07-24 15:12:26 +0200
commit2d472b48610f6a298d28035b683ab13e9afac4cb (patch)
tree6099ab0b6662e7d3f933b1f3350041aa3f269070
parentc437631485a85c3bd034e12f53dd1c8207f05940 (diff)
downloadglibc-2d472b48610f6a298d28035b683ab13e9afac4cb.tar.gz
glibc-2d472b48610f6a298d28035b683ab13e9afac4cb.tar.xz
glibc-2d472b48610f6a298d28035b683ab13e9afac4cb.zip
nscd: Use errval, not errno to guide cache update (bug 30662)
The errno variable is potentially clobbered by the preceding
send call.  It is not related to the to-be-cached information.
The parallel code in hstcache.c and servicescache.c already uses
errval.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
-rw-r--r--nscd/grpcache.c2
-rw-r--r--nscd/pwdcache.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/nscd/grpcache.c b/nscd/grpcache.c
index cdd1071970..2d01b84519 100644
--- a/nscd/grpcache.c
+++ b/nscd/grpcache.c
@@ -116,7 +116,7 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req,
 
 	  /* If we have a transient error or cannot permanently store
 	     the result, so be it.  */
-	  if (errno == EAGAIN || __builtin_expect (db->negtimeout == 0, 0))
+	  if (errval == EAGAIN || __glibc_unlikely (db->negtimeout == 0))
 	    {
 	      /* Mark the old entry as obsolete.  */
 	      if (dh != NULL)
diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c
index e1b579de6b..e5d51e74ff 100644
--- a/nscd/pwdcache.c
+++ b/nscd/pwdcache.c
@@ -122,7 +122,7 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req,
 
 	  /* If we have a transient error or cannot permanently store
 	     the result, so be it.  */
-	  if (errno == EAGAIN || __builtin_expect (db->negtimeout == 0, 0))
+	  if (errval == EAGAIN || __glibc_unlikely (db->negtimeout == 0))
 	    {
 	      /* Mark the old entry as obsolete.  */
 	      if (dh != NULL)