|
|
ce426f |
commit 31d0a4fa646db8b8c97ce24e0ec0a7b73de4fca1
|
|
|
ce426f |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
ce426f |
Date: Sat Jun 11 12:12:56 2016 +0200
|
|
|
ce426f |
|
|
|
ce426f |
nss_db: Fix initialization of iteration position [BZ #20237]
|
|
|
ce426f |
|
|
|
ce426f |
When get*ent is called without a preceding set*ent, we need
|
|
|
ce426f |
to set the initial iteration position in get*ent.
|
|
|
ce426f |
|
|
|
ce426f |
Reproducer: Add “services: db files” to /etc/nsswitch.conf, then run
|
|
|
ce426f |
“perl -e getservent”. It will segfault before this change, and exit
|
|
|
ce426f |
silently after it.
|
|
|
ce426f |
|
|
|
ce426f |
Index: b/nss/nss_db/db-XXX.c
|
|
|
ce426f |
===================================================================
|
|
|
ce426f |
--- a/nss/nss_db/db-XXX.c
|
|
|
ce426f |
+++ b/nss/nss_db/db-XXX.c
|
|
|
ce426f |
@@ -76,7 +76,7 @@ CONCAT(_nss_db_set,ENTNAME) (int stayope
|
|
|
ce426f |
keep_db |= stayopen;
|
|
|
ce426f |
|
|
|
ce426f |
/* Reset the sequential index. */
|
|
|
ce426f |
- entidx = (const char *) state.header + state.header->valstroffset;
|
|
|
ce426f |
+ entidx = NULL;
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
__libc_lock_unlock (lock);
|
|
|
ce426f |
@@ -249,8 +249,14 @@ CONCAT(_nss_db_get,ENTNAME_r) (struct ST
|
|
|
ce426f |
H_ERRNO_SET (NETDB_INTERNAL);
|
|
|
ce426f |
goto out;
|
|
|
ce426f |
}
|
|
|
ce426f |
+ entidx = NULL;
|
|
|
ce426f |
}
|
|
|
ce426f |
|
|
|
ce426f |
+ /* Start from the beginning if freshly initialized or reset
|
|
|
ce426f |
+ requested by set*ent. */
|
|
|
ce426f |
+ if (entidx == NULL)
|
|
|
ce426f |
+ entidx = (const char *) state.header + state.header->valstroffset;
|
|
|
ce426f |
+
|
|
|
ce426f |
status = NSS_STATUS_UNAVAIL;
|
|
|
ce426f |
if (state.header != MAP_FAILED)
|
|
|
ce426f |
{
|