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.
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 *);
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
rv = __getpw_a(name, uid, pw, &line, &len, res);
- if (!rv && size < len) {
+ if (*res && size < len) {
*res = 0;
rv = ERANGE;
}
- if (!rv) {
+ if (*res) {
memcpy(buf, line, len);
FIX(name);
FIX(passwd);