summaryrefslogtreecommitdiffstats
path: root/lib/libc/gen/getgrent.c
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2004-05-17 22:15:49 +0000
committerkientzle <kientzle@FreeBSD.org>2004-05-17 22:15:49 +0000
commit330e353d70b4e66999db3be3f44e56bfe0515cb1 (patch)
treecb7059c9c4c0cb0b291db3e1b90f902db9e5cff6 /lib/libc/gen/getgrent.c
parent4070a4a8d4f684242bddd0ac9a1e6c999dd11ded (diff)
downloadFreeBSD-src-330e353d70b4e66999db3be3f44e56bfe0515cb1.zip
FreeBSD-src-330e353d70b4e66999db3be3f44e56bfe0515cb1.tar.gz
getgrent() and friends should set errno if there is an error.
Also, clarify the manpage description of when errno is set and explain that clients should set errno=0 first if they want useful error information.
Diffstat (limited to 'lib/libc/gen/getgrent.c')
-rw-r--r--lib/libc/gen/getgrent.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c
index d834d09..c9b7474 100644
--- a/lib/libc/gen/getgrent.c
+++ b/lib/libc/gen/getgrent.c
@@ -307,6 +307,7 @@ getgr(int (*fn)(union key, struct group *, char *, size_t, struct group **),
free(grp_storage);
if ((grp_storage_size << 1) > GRP_STORAGE_MAX) {
grp_storage = NULL;
+ errno = ERANGE;
return (NULL);
}
grp_storage_size <<= 1;
@@ -315,6 +316,8 @@ getgr(int (*fn)(union key, struct group *, char *, size_t, struct group **),
return (NULL);
}
} while (res == NULL && rv == ERANGE);
+ if (rv != 0)
+ errno = rv;
return (res);
}
OpenPOWER on IntegriCloud