summaryrefslogtreecommitdiff
path: root/src/passwd/getgr_a.c
AgeCommit message (Collapse)AuthorLines
42 hoursgetgr*: validate group member lists from nscd backendRich Felker-1/+11
this corrects missing validation when using alternate group database backends via nscd, as reported by 0rbitingZer0, which could result in a heap-based buffer overflow. while the source of truth for user (passwd) and group definitions is generally an equal or higher-privilege domain than the application, and compromise of nscd could inherently lead to bypass of some access controls, it is still worthwhile to harden against direct attacks from a compromised nscd. this patch adds validation in the least invasive way possible, erroring out at the point where a write past the end of the buffer would previously have occurred. a check is also added for member counts that would cause arithmetic overflow in the existing buffer size computations, including negative counts. this could be handled better by making adjustments where the arithmetic is performed, but the way it's done here avoids making any changes except for the actual bounds check.
2015-03-15simplify nscd lookup code for alt passwd/group backendsRich Felker-1/+0
previously, a sentinel value of (FILE *)-1 was used to inform the caller of __nscd_query that nscd is not in use. aside from being an ugly hack, this resulted in duplicate code paths for two logically equivalent cases: no nscd, and "not found" result from nscd. now, __nscd_query simply skips closing the socket and returns a valid FILE pointer when nscd is not in use, and produces a fake "not found" response header. the caller is then responsible for closing the socket just like it would do if it had gotten a real "not found" response.
2015-02-23support alternate backends for the passwd and group dbsJosiah Worcester-1/+139
when we fail to find the entry in the commonly accepted files, we query a server over a Unix domain socket on /var/run/nscd/socket. the protocol used here is compatible with glibc's nscd protocol on most systems (all that use 32-bit numbers for all the protocol fields, which appears to be everything but Alpha).
2015-02-13refactor group file access codeJosiah Worcester-0/+32
this allows getgrnam and getgrgid to share code with the _r versions in preparation for alternate backend support.