aboutsummaryrefslogtreecommitdiff
path: root/pwd
diff options
context:
space:
mode:
Diffstat (limited to 'pwd')
-rw-r--r--pwd/fgetpwent_r.c13
-rw-r--r--pwd/getpw.c4
2 files changed, 13 insertions, 4 deletions
diff --git a/pwd/fgetpwent_r.c b/pwd/fgetpwent_r.c
index 87ea1dedda..78b491d386 100644
--- a/pwd/fgetpwent_r.c
+++ b/pwd/fgetpwent_r.c
@@ -21,6 +21,10 @@
#include <stdio.h>
#include <pwd.h>
+#ifdef USE_IN_LIBIO
+# define flockfile(s) _IO_flockfile (s)
+#endif
+
/* Define a line parsing function using the common code
used in the nss_files module. */
@@ -72,17 +76,20 @@ __fgetpwent_r (FILE *stream, struct passwd *resbuf, char *buffer,
{
char *p;
+ 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;
}
@@ -95,6 +102,8 @@ __fgetpwent_r (FILE *stream, struct passwd *resbuf, char *buffer,
get the next line of the file to parse. */
! parse_line (p, resbuf, (void *) buffer, buflen, &errno));
+ funlockfile (stream);
+
*result = resbuf;
return 0;
}
diff --git a/pwd/getpw.c b/pwd/getpw.c
index 9c2e4afd0a..5f738724a9 100644
--- a/pwd/getpw.c
+++ b/pwd/getpw.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1996, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -47,7 +47,7 @@ __getpw (uid, buf)
buflen = __sysconf (_SC_GETPW_R_SIZE_MAX);
tmpbuf = alloca (buflen);
- if (getpwuid_r (uid, &resbuf, tmpbuf, buflen, &p) < 0)
+ if (__getpwuid_r (uid, &resbuf, tmpbuf, buflen, &p) < 0)
return -1;
if (sprintf (buf, "%s:%s:%u:%u:%s:%s:%s", p->pw_name, p->pw_passwd,