]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
libc/nss: Restore iterator state when doing passwd/group lookups
authorMark Johnston <markj@FreeBSD.org>
Thu, 21 Jan 2021 19:30:19 +0000 (14:30 -0500)
committerMark Johnston <markj@FreeBSD.org>
Thu, 21 Jan 2021 19:30:19 +0000 (14:30 -0500)
commit5619d49e07d3942e438f3d06269f3c1c466cf5b7
tree811c4c808e657eef2f31c9570a4470e62fb7b6b3
parent7abc10098b3d9c23d611294714b3058e8048aec0
libc/nss: Restore iterator state when doing passwd/group lookups

The getpwent(3) and getgrent(3) implementations maintain some internal
iterator state.  Interleaved calls to functions which do passwd/group
lookups using a key, such as getpwnam(3), would in some cases clobber
this state, causing a subsequent getpwent() or getgrent() call to
restart iteration from the beginning of the database or to terminate
early.  This is particularly troublesome in programming environments
where execution of green threads is interleaved within a single OS
thread.

Take care to restore any iterator state following a keyed lookup.  The
"files" provider for the passwd database was already handling this
correctly, but "compat" was not, and both providers had this problem
when accessing the group database.

PR: 252094
Submitted by: Viktor Dukhovni <ietf-dane@dukhovni.org>
MFC after: 1 month
lib/libc/gen/getgrent.c
lib/libc/gen/getpwent.c