Blame SOURCES/glibc-rh1698015.patch

147e83
commit 99135114ba23c3110b7e4e650fabdc5e639746b7
147e83
Author: DJ Delorie <dj@redhat.com>
147e83
Date:   Fri Jun 28 18:30:00 2019 -0500
147e83
147e83
    nss_db: fix endent wrt NULL mappings [BZ #24695] [BZ #24696]
147e83
    
147e83
    nss_db allows for getpwent et al to be called without a set*ent,
147e83
    but it only works once.  After the last get*ent a set*ent is
147e83
    required to restart, because the end*ent did not properly reset
147e83
    the module.  Resetting it to NULL allows for a proper restart.
147e83
    
147e83
    If the database doesn't exist, however, end*ent erroniously called
147e83
    munmap which set errno.
147e83
147e83
Note: the test case has not been included in this backport as the
147e83
required test harness infrastructure does not exist.
147e83
    
147e83
diff --git a/nss/nss_db/db-open.c b/nss/nss_db/db-open.c
147e83
index 8a83d6b..3fa11e9 100644
147e83
--- a/nss/nss_db/db-open.c
147e83
+++ b/nss/nss_db/db-open.c
147e83
@@ -63,5 +63,9 @@ internal_setent (const char *file, struct nss_db_map *mapping)
147e83
 void
147e83
 internal_endent (struct nss_db_map *mapping)
147e83
 {
147e83
-  munmap (mapping->header, mapping->len);
147e83
+  if (mapping->header != NULL)
147e83
+    {
147e83
+      munmap (mapping->header, mapping->len);
147e83
+      mapping->header = NULL;
147e83
+    }
147e83
 }