[PATCH 2/2] lock_pool: check err instead of errno

Ruben Kerkhof ruben at rubenkerkhof.com
Thu Aug 11 16:08:35 CEST 2016


The errno set by mlock() is overwritten by the call to the next system
function.
---
 src/secmem.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/secmem.c b/src/secmem.c
index c4e8414..59f75b4 100644
--- a/src/secmem.c
+++ b/src/secmem.c
@@ -264,15 +264,15 @@ lock_pool (void *p, size_t n)
 
   if (err)
     {
-      if (errno != EPERM
+      if (err != EPERM
 #ifdef EAGAIN	/* OpenBSD returns this */
-	  && errno != EAGAIN
+	  && err != EAGAIN
 #endif
 #ifdef ENOSYS	/* Some SCOs return this (function not implemented) */
-	  && errno != ENOSYS
+	  && err != ENOSYS
 #endif
 #ifdef ENOMEM  /* Linux might return this. */
-            && errno != ENOMEM
+            && err != ENOMEM
 #endif
 	  )
 	log_error ("can't lock memory: %s\n", strerror (err));
@@ -323,15 +323,15 @@ lock_pool (void *p, size_t n)
 
   if (err)
     {
-      if (errno != EPERM
+      if (err != EPERM
 #ifdef EAGAIN	/* OpenBSD returns this. */
-	  && errno != EAGAIN
+	  && err != EAGAIN
 #endif
 #ifdef ENOSYS	/* Some SCOs return this (function not implemented). */
-	  && errno != ENOSYS
+	  && err != ENOSYS
 #endif
 #ifdef ENOMEM  /* Linux might return this. */
-            && errno != ENOMEM
+            && err != ENOMEM
 #endif
 	  )
 	log_error ("can't lock memory: %s\n", strerror (err));
-- 
2.9.2




More information about the Gcrypt-devel mailing list