about summary refs log tree commit diff
path: root/misc
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-07-05 12:05:16 +0000
committerUlrich Drepper <drepper@redhat.com>1998-07-05 12:05:16 +0000
commit71412a8c76fe28a62a2acf243f5ae4e91ddf632e (patch)
tree9da097ba8307f2f6de872968566071cc4eac3b1f /misc
parent6777b467cec0f1bee82bbd5098bcfa006268fd9c (diff)
downloadglibc-71412a8c76fe28a62a2acf243f5ae4e91ddf632e.tar.gz
glibc-71412a8c76fe28a62a2acf243f5ae4e91ddf632e.tar.xz
glibc-71412a8c76fe28a62a2acf243f5ae4e91ddf632e.zip
Update.
1998-07-05 11:49  Ulrich Drepper  <drepper@cygnus.com>

	* iconv/gconv_conf.c (read_conf_file): Use feof_unlocked on private
	stream.
	* inet/ruserpass.c (token): Likewise.
	* nss/nsswitch.c (nss_parse_file): Likewise.
	* intl/localealias.c: Likewise.  Also for ferror.
	* time/getdate.c (__getdate_r): Likewise.

	* libio/Makefile (routines): Add iofgets_u.
	* libio/iofgets_u.c: New file.
	* libio/Versions: Add fgets_unlocked.
	* libio/stdio.h: Add prototype for fgets_unlocked.

	* misc/getttyent.c (getttyent): Use fgets_unlocked instead of fgets.
	* misc/getusershell.c (initshells): Likewise.
	* misc/mntent_r.c (__getmntent_r): Explicitly lock stream.  Use
	fgets_unlocked.
	* nss/nss_files/files-XXX.c (internal_getent): Likewise.
	* resolv/res_init.c (res_init): Likewise.
	* sysdeps/unix/sysv/linux/getsysstats.c: Likewise.
Diffstat (limited to 'misc')
-rw-r--r--misc/getttyent.c2
-rw-r--r--misc/getusershell.c4
-rw-r--r--misc/mntent_r.c8
3 files changed, 9 insertions, 5 deletions
diff --git a/misc/getttyent.c b/misc/getttyent.c
index f474cdcacf..07018f7051 100644
--- a/misc/getttyent.c
+++ b/misc/getttyent.c
@@ -73,7 +73,7 @@ getttyent()
 		return (NULL);
 	flockfile (tf);
 	for (;;) {
-		if (!fgets(p = line, sizeof(line), tf))
+		if (!fgets_unlocked(p = line, sizeof(line), tf))
 			return (NULL);
 		/* skip lines that are too big */
 		if (!index(p, '\n')) {
diff --git a/misc/getusershell.c b/misc/getusershell.c
index 6b210b68ff..d822f554ea 100644
--- a/misc/getusershell.c
+++ b/misc/getusershell.c
@@ -96,6 +96,7 @@ initshells()
 	register char **sp, *cp;
 	register FILE *fp;
 	struct stat statb;
+	int flen;
 
 	if (shells != NULL)
 		free(shells);
@@ -122,7 +123,8 @@ initshells()
 	}
 	sp = shells;
 	cp = strings;
-	while (fgets(cp, statb.st_size - (cp - strings), fp) != NULL) {
+	flen = statb.st_size;
+	while (fgets_unlocked(cp, flen - (cp - strings), fp) != NULL) {
 		while (*cp != '#' && *cp != '/' && *cp != '\0')
 			cp++;
 		if (*cp == '#' || *cp == '\0')
diff --git a/misc/mntent_r.c b/misc/mntent_r.c
index 4dc0358f03..9567a6f077 100644
--- a/misc/mntent_r.c
+++ b/misc/mntent_r.c
@@ -1,5 +1,5 @@
 /* Utilities for reading/writing fstab, mtab, etc.
-   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 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
@@ -51,11 +51,12 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
 {
   char *head;
 
+  flockfile (stream);
   do
     {
       char *end_ptr;
 
-      if (fgets (buffer, bufsiz, stream) == NULL)
+      if (fgets_unlocked (buffer, bufsiz, stream) == NULL)
 	return NULL;
 
       end_ptr = strchr (buffer, '\n');
@@ -65,7 +66,7 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
 	{
 	  /* Not the whole line was read.  Do it now but forget it.  */
 	  char tmp[1024];
-	  while (fgets (tmp, sizeof tmp, stream) != NULL)
+	  while (fgets_unlocked (tmp, sizeof tmp, stream) != NULL)
 	    if (strchr (tmp, '\n') != NULL)
 	      break;
 	}
@@ -92,6 +93,7 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
       mp->mnt_passno = 0;
     case 2:
     }
+  funlockfile (stream);
 
   return mp;
 }