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