mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
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.
This commit is contained in:
parent
922013a665
commit
9b8f137b2d
2 changed files with 8 additions and 1 deletions
|
|
@ -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 ,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue