summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorTim Kientzle <kientzle@FreeBSD.org>2004-05-17 22:15:49 +0000
committerTim Kientzle <kientzle@FreeBSD.org>2004-05-17 22:15:49 +0000
commit9b8f137b2dba944e685f035db6d33181706c3856 (patch)
treecb7059c9c4c0cb0b291db3e1b90f902db9e5cff6 /lib/libc
parent922013a665242b38cb20a64fda41629f30996424 (diff)
Notes
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/getgrent.36
-rw-r--r--lib/libc/gen/getgrent.c3
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/libc/gen/getgrent.3 b/lib/libc/gen/getgrent.3
index be37567299c5..838e1070328b 100644
--- a/lib/libc/gen/getgrent.3
+++ b/lib/libc/gen/getgrent.3
@@ -168,9 +168,13 @@ and
return a pointer to a group structure on success or
.Dv NULL
if the entry is not found or if an error occurs.
-In the latter case,
+If an error does occur,
.Va errno
will be set.
+Note that programs must explicitly set
+.Va errno
+to zero before calling any of these functions if they need to
+distinguish between a non-existent entry and an error.
The functions
.Fn getgrent_r ,
.Fn getgrnam_r ,
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c
index d834d09fc9e6..c9b7474e78d7 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);
}