diff options
Diffstat (limited to 'grp')
-rw-r--r-- | grp/fgetgrent_r.c | 15 | ||||
-rw-r--r-- | grp/initgroups.c | 4 |
2 files changed, 15 insertions, 4 deletions
diff --git a/grp/fgetgrent_r.c b/grp/fgetgrent_r.c index 0c87815..4abadfd 100644 --- a/grp/fgetgrent_r.c +++ b/grp/fgetgrent_r.c @@ -21,6 +21,12 @@ #include <grp.h> #include <stdio.h> +#ifdef USE_IN_LIBIO +# include <libio/iolibio.h> +# define flockfile(s) _IO_flockfile (s) +# define funlockfile(s) _IO_funlockfile (s) +#endif + /* Define a line parsing function using the common code used in the nss_files module. */ @@ -59,17 +65,20 @@ __fgetgrent_r (FILE *stream, struct group *resbuf, char *buffer, size_t buflen, char *p; int parse_result; + flockfile (stream); do { buffer[buflen - 1] = '\xff'; - p = fgets (buffer, buflen, stream); - if (p == NULL && feof (stream)) + p = fgets_unlocked (buffer, buflen, stream); + if (p == NULL && feof_unlocked (stream)) { + funlockfile (stream); *result = NULL; return errno; } if (p == NULL || buffer[buflen - 1] != '\xff') { + funlockfile (stream); *result = NULL; return errno = ERANGE; } @@ -84,6 +93,8 @@ __fgetgrent_r (FILE *stream, struct group *resbuf, char *buffer, size_t buflen, (void *) buffer, buflen, &errno))); + funlockfile (stream); + if (parse_result == -1) { /* The parser ran out of space. */ diff --git a/grp/initgroups.c b/grp/initgroups.c index d74d08d..082c49f 100644 --- a/grp/initgroups.c +++ b/grp/initgroups.c @@ -52,7 +52,7 @@ compat_call (service_user *nip, const char *user, gid_t group, long int *start, long int *size, gid_t *groups, long int limit, int *errnop) { struct group grpbuf, *g; - size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX); + size_t buflen = __sysconf (_SC_GETPW_R_SIZE_MAX); char *tmpbuf; enum nss_status status; set_function setgrent_fct; @@ -155,7 +155,7 @@ initgroups (user, group) size = limit; #else - long int limit = sysconf (_SC_NGROUPS_MAX); + long int limit = __sysconf (_SC_NGROUPS_MAX); if (limit > 0) size = limit; |