diff options
author | Rich Felker <dalias@aerifal.cx> | 2015-02-23 00:35:47 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2015-02-23 00:35:47 -0500 |
commit | fc5a96c9c8aa186effad7520d5df6b616bbfd29d (patch) | |
tree | eeeba8f6c0cfdeafaa5955e29104850a9d7c8c68 /src/passwd/getgr_r.c | |
parent | d9da1fb8c592469431c764732d09f7756340190e (diff) | |
download | musl-fc5a96c9c8aa186effad7520d5df6b616bbfd29d.tar.gz musl-fc5a96c9c8aa186effad7520d5df6b616bbfd29d.tar.xz musl-fc5a96c9c8aa186effad7520d5df6b616bbfd29d.zip |
fix crashes in refactored passwd/group code
the wrong condition was used in determining the presence of a result that needs space/copying for the _r functions. a zero return value does not necessarily mean success; it can also be a non-error negative result: no such user/group.
Diffstat (limited to 'src/passwd/getgr_r.c')
-rw-r--r-- | src/passwd/getgr_r.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/passwd/getgr_r.c b/src/passwd/getgr_r.c index 68b867d8..7246e8a4 100644 --- a/src/passwd/getgr_r.c +++ b/src/passwd/getgr_r.c @@ -16,11 +16,11 @@ static int getgr_r(const char *name, gid_t gid, struct group *gr, char *buf, siz pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs); rv = __getgr_a(name, gid, gr, &line, &len, &mem, &nmem, res); - if (!rv && size < len + (nmem+1)*sizeof(char *) + 32) { + if (*res && size < len + (nmem+1)*sizeof(char *) + 32) { *res = 0; rv = ERANGE; } - if (!rv) { + if (*res) { buf += (16-(uintptr_t)buf)%16; gr->gr_mem = (void *)buf; buf += (nmem+1)*sizeof(char *); |