<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/lib/libc/gen/getpwent.c, branch releng/12.4</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src/atom?h=releng%2F12.4</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src/atom?h=releng%2F12.4'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/'/>
<updated>2021-02-20T16:35:32Z</updated>
<entry>
<title>libc/nss: Restore iterator state when doing passwd/group lookups</title>
<updated>2021-02-20T16:35:32Z</updated>
<author>
<name>Mark Johnston</name>
<email>markj@FreeBSD.org</email>
</author>
<published>2021-01-21T19:30:19Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=a8499077ab1b23c432c251874cf931e1025d8636'/>
<id>urn:sha1:a8499077ab1b23c432c251874cf931e1025d8636</id>
<content type='text'>
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 &lt;ietf-dane@dukhovni.org&gt;

(cherry picked from commit 5619d49e07d3942e438f3d06269f3c1c466cf5b7)
</content>
</entry>
<entry>
<title>MFC r365910:</title>
<updated>2020-11-26T23:34:02Z</updated>
<author>
<name>Alan Somers</name>
<email>asomers@FreeBSD.org</email>
</author>
<published>2020-11-26T23:34:02Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=cf058833feeb9a16187b39ee652bdae81824899d'/>
<id>urn:sha1:cf058833feeb9a16187b39ee652bdae81824899d</id>
<content type='text'>
fix integer underflow in getgrnam_r and getpwnam_r

Sometimes nscd(8) will return a 1-byte buffer for a nonexistent entry. This
triggered an integer underflow in grp_unmarshal_func, causing getgrnam_r to
return ERANGE instead of 0.

Fix the user's buffer size check, and add a correct check for a too-small
nscd buffer.

PR:		248932
Event:		September 2020 Bugathon
Reviewed by:	markj
Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D26204
</content>
</entry>
<entry>
<title>MFC r359978:</title>
<updated>2020-04-27T23:47:40Z</updated>
<author>
<name>Brooks Davis</name>
<email>brooks@FreeBSD.org</email>
</author>
<published>2020-04-27T23:47:40Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=33b80acf60a1cdf0390c7acc33f13022c7a9515b'/>
<id>urn:sha1:33b80acf60a1cdf0390c7acc33f13022c7a9515b</id>
<content type='text'>
Fix -Wvoid-pointer-to-enum-cast warnings.

This pattern is used in callbacks with void * data arguments and seems
both relatively uncommon and relatively harmless.  Silence the warning
by casting through uintptr_t.

This warning is on by default in Clang 11.

Reviewed by:	arichardson
Obtained from:	CheriBSD (partial)
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24425
</content>
</entry>
<entry>
<title>Make pw_scan(3) more compatible with getpwent(3) et. al. when processing</title>
<updated>2018-07-26T18:34:38Z</updated>
<author>
<name>Ian Lepore</name>
<email>ian@FreeBSD.org</email>
</author>
<published>2018-07-26T18:34:38Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=34e9190d82ac021bae00937cc1a663920aa19309'/>
<id>urn:sha1:34e9190d82ac021bae00937cc1a663920aa19309</id>
<content type='text'>
data from /etc/passwd rather than /etc/master.passwd.

The libc getpwent(3) and related functions automatically read master.passwd
when run by root, or passwd when run by a non-root user.  When run by non-
root, getpwent() copes with the missing data by setting the corresponding
fields in the passwd struct to known values (zeroes for numbers, or a
pointer to an empty string for literals).  When libutil's pw_scan(3) was
used to parse a line without the root-accessible data, it was leaving
garbage in the corresponding fields.

These changes rename the static pw_init() function used by getpwent() and
friends to __pw_initpwd(), and move it into pw_scan.c so that common init
code can be shared between libc and libutil.  pw_scan(3) now calls
__pw_initpwd() before __pw_scan(), just like the getpwent() family does, so
that reading an arbitrary passwd file in either format and parsing it with
pw_scan(3) returns the same results as getpwent(3) would.

This also adds a new pw_initpwd(3) function to libutil, so that code which
creates passwd structs from scratch in some manner that doesn't involve
pw_scan() can initialize the struct to the values expected by lots of
existing code, which doesn't expect to encounter NULL pointers or garbage
values in some fields.
</content>
</entry>
<entry>
<title>libc: further adoption of SPDX licensing ID tags.</title>
<updated>2017-11-25T17:12:48Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2017-11-25T17:12:48Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=d915a14ef094c8dfc1a5aee70e135abfec01d0f1'/>
<id>urn:sha1:d915a14ef094c8dfc1a5aee70e135abfec01d0f1</id>
<content type='text'>
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using mis-identified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
</content>
</entry>
<entry>
<title>libc: make some more use of the nitems() macro.</title>
<updated>2016-04-16T17:52:00Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2016-04-16T17:52:00Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=bf51882a09fb19789665c0b385c5fa2f51331079'/>
<id>urn:sha1:bf51882a09fb19789665c0b385c5fa2f51331079</id>
<content type='text'>
We have an nitems() macro in the &lt;sys/param.h&gt; header that is
convenient to re-use as it makes things easier to read.
Given that it is available already without adding additional
headers and other parts of libc already use it, extend a bit
more its use.
</content>
</entry>
<entry>
<title>Fix compiling with gcc [4.2.1] after r287797 when MK_HESOID == no and</title>
<updated>2015-10-25T07:42:56Z</updated>
<author>
<name>Enji Cooper</name>
<email>ngie@FreeBSD.org</email>
</author>
<published>2015-10-25T07:42:56Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=3e973f9b6df8c006b71f738957a3791bdb7ad0e3'/>
<id>urn:sha1:3e973f9b6df8c006b71f738957a3791bdb7ad0e3</id>
<content type='text'>
MK_NIS == no by converting `i` back to an int, and instead cast the loop
comparison to `int`

The loop comparison is iterating the len(ns_dtab)-1, because
the last element is the sentinel tuple { NULL, NULL, NULL, }, so when
both HESOID and NIS are off, len(ns_dtab)-1 == 1 - 1 == 0, and the loop
is skipped because the expression is tautologically false

While here, convert `(sizeof(x) / sizeof(x[0]))` to `nitems(x)`

Tested with: clang 3.7.0, gcc 4.2.1, and gcc 4.9.4 [*] with MK_NIS={no,yes}
             and by running bash -lc 'id -u &amp;&amp; id -g &amp;&amp; id'

* gcc 4.9.4 needs another patch in order for the compile to succeed
  with -Werror with lib/libc/gen/getgrent.c

Reported by: jhibbits
</content>
</entry>
<entry>
<title>Use unsigned variables in a few places.</title>
<updated>2015-09-14T18:59:01Z</updated>
<author>
<name>Craig Rodrigues</name>
<email>rodrigc@FreeBSD.org</email>
</author>
<published>2015-09-14T18:59:01Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=e263ec16a93844ceb2f1686f86fe019cd00b0ba8'/>
<id>urn:sha1:e263ec16a93844ceb2f1686f86fe019cd00b0ba8</id>
<content type='text'>
Eliminates gcc 4.9 warnings.
</content>
</entry>
<entry>
<title>compat_passwd(): yet another uninitialized access to stayopen.</title>
<updated>2015-03-06T22:22:57Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2015-03-06T22:22:57Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=b3d078e66658bc68dda915bb6a786e2f07d2483d'/>
<id>urn:sha1:b3d078e66658bc68dda915bb6a786e2f07d2483d</id>
<content type='text'>
CID:	1018731
</content>
</entry>
<entry>
<title>Fix small memleaks in nis_passwd() and nis_group().</title>
<updated>2015-02-20T01:02:32Z</updated>
<author>
<name>Pedro F. Giffuni</name>
<email>pfg@FreeBSD.org</email>
</author>
<published>2015-02-20T01:02:32Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=a69a20fa131fa967bce22d8df3b5cd8f7d8ee18c'/>
<id>urn:sha1:a69a20fa131fa967bce22d8df3b5cd8f7d8ee18c</id>
<content type='text'>
These only occur upon error.

Code Review:	https://reviews.freebsd.org/D1849
Reviewed by:	delphij

CID:	1016715
CID:	1016717
</content>
</entry>
</feed>
