mirror of
git://git.musl-libc.org/musl
synced 2025-03-06 20:48:29 +01:00
fix getgrouplist when nscd reports an empty list
commit 500c6886c6
broke this by fixing
the behavior of fread to conform to the C standard; getgroupslist was
assuming the old behavior, that a request to read 1 member of length 0
would return 1, not 0.
This commit is contained in:
parent
b7bc966522
commit
da845d52c5
1 changed files with 2 additions and 1 deletions
|
@ -31,7 +31,8 @@ int getgrouplist(const char *user, gid_t gid, gid_t *groups, int *ngroups)
|
|||
if (resp[INITGRFOUND]) {
|
||||
nscdbuf = calloc(resp[INITGRNGRPS], sizeof(uint32_t));
|
||||
if (!nscdbuf) goto cleanup;
|
||||
if (!fread(nscdbuf, sizeof(*nscdbuf)*resp[INITGRNGRPS], 1, f)) {
|
||||
size_t nbytes = sizeof(*nscdbuf)*resp[INITGRNGRPS];
|
||||
if (nbytes && !fread(nscdbuf, nbytes, 1, f)) {
|
||||
if (!ferror(f)) errno = EIO;
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue