* [2.23 COMMITTED] nss_db: Fix initialization of iteration position [BZ #20237]
@ 2016-01-01 0:00 Florian Weimer
0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2016-01-01 0:00 UTC (permalink / raw)
To: libc-stable
When get*ent is called without a preceding set*ent, we need
to set the initial iteration position in get*ent.
Reproducer: Add âservices: db filesâ to /etc/nsswitch.conf, then run
âperl -e getserventâ. It will segfault before this change, and exit
silently after it.
(cherry picked from commit 31d0a4fa646db8b8c97ce24e0ec0a7b73de4fca1)
2016-06-11 Florian Weimer <fweimer@redhat.com>
[BZ #20237]
* nss/nss_db/db-XXX.c (set*ent): Reset entidx to NULL.
(get*ent): Set entidx to NULL during initialization. If entidx is
NULL, start iteration from the beginning.
diff --git a/nss/nss_db/db-XXX.c b/nss/nss_db/db-XXX.c
index 125a5e9..2d13edd 100644
--- a/nss/nss_db/db-XXX.c
+++ b/nss/nss_db/db-XXX.c
@@ -77,7 +77,7 @@ CONCAT(_nss_db_set,ENTNAME) (int stayopen)
keep_db |= stayopen;
/* Reset the sequential index. */
- entidx = (const char *) state.header + state.header->valstroffset;
+ entidx = NULL;
}
__libc_lock_unlock (lock);
@@ -253,8 +253,14 @@ CONCAT(_nss_db_get,ENTNAME_r) (struct STRUCTURE *result, char *buffer,
H_ERRNO_SET (NETDB_INTERNAL);
goto out;
}
+ entidx = NULL;
}
+ /* Start from the beginning if freshly initialized or reset
+ requested by set*ent. */
+ if (entidx == NULL)
+ entidx = (const char *) state.header + state.header->valstroffset;
+
status = NSS_STATUS_UNAVAIL;
if (state.header != MAP_FAILED)
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-18 13:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-01 0:00 [2.23 COMMITTED] nss_db: Fix initialization of iteration position [BZ #20237] Florian Weimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).