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.
This commit is contained in:
Ulrich Drepper 1998-07-05 12:05:16 +00:00
parent 6777b467ce
commit 71412a8c76
9 changed files with 39 additions and 13 deletions

View File

@ -1,3 +1,25 @@
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.
1998-05-23 Philip Blundell <Philip.Blundell@pobox.com> 1998-05-23 Philip Blundell <Philip.Blundell@pobox.com>
* sysdeps/unix/sysv/linux/arm/syscalls.list: Add `syscall'. * sysdeps/unix/sysv/linux/arm/syscalls.list: Add `syscall'.

View File

@ -73,7 +73,7 @@ getttyent()
return (NULL); return (NULL);
flockfile (tf); flockfile (tf);
for (;;) { for (;;) {
if (!fgets(p = line, sizeof(line), tf)) if (!fgets_unlocked(p = line, sizeof(line), tf))
return (NULL); return (NULL);
/* skip lines that are too big */ /* skip lines that are too big */
if (!index(p, '\n')) { if (!index(p, '\n')) {

View File

@ -96,6 +96,7 @@ initshells()
register char **sp, *cp; register char **sp, *cp;
register FILE *fp; register FILE *fp;
struct stat statb; struct stat statb;
int flen;
if (shells != NULL) if (shells != NULL)
free(shells); free(shells);
@ -122,7 +123,8 @@ initshells()
} }
sp = shells; sp = shells;
cp = strings; 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') while (*cp != '#' && *cp != '/' && *cp != '\0')
cp++; cp++;
if (*cp == '#' || *cp == '\0') if (*cp == '#' || *cp == '\0')

View File

@ -1,5 +1,5 @@
/* Utilities for reading/writing fstab, mtab, etc. /* 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. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or 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; char *head;
flockfile (stream);
do do
{ {
char *end_ptr; char *end_ptr;
if (fgets (buffer, bufsiz, stream) == NULL) if (fgets_unlocked (buffer, bufsiz, stream) == NULL)
return NULL; return NULL;
end_ptr = strchr (buffer, '\n'); 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. */ /* Not the whole line was read. Do it now but forget it. */
char tmp[1024]; char tmp[1024];
while (fgets (tmp, sizeof tmp, stream) != NULL) while (fgets_unlocked (tmp, sizeof tmp, stream) != NULL)
if (strchr (tmp, '\n') != NULL) if (strchr (tmp, '\n') != NULL)
break; break;
} }
@ -92,6 +93,7 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz)
mp->mnt_passno = 0; mp->mnt_passno = 0;
case 2: case 2:
} }
funlockfile (stream);
return mp; return mp;
} }

View File

@ -181,7 +181,7 @@ internal_getent (struct STRUCTURE *result,
/* Terminate the line so that we can test for overflow. */ /* Terminate the line so that we can test for overflow. */
data->linebuffer[linebuflen - 1] = '\xff'; data->linebuffer[linebuflen - 1] = '\xff';
p = fgets (data->linebuffer, linebuflen, stream); p = fgets_unlocked (data->linebuffer, linebuflen, stream);
if (p == NULL) if (p == NULL)
{ {
/* End of file or read error. */ /* End of file or read error. */

View File

@ -536,7 +536,7 @@ nss_parse_file (const char *fname)
last = this; last = this;
} }
} }
while (!feof (fp)); while (!feof_unlocked (fp));
/* Free the buffer. */ /* Free the buffer. */
free (line); free (line);

View File

@ -259,7 +259,7 @@ res_init()
#endif #endif
if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
/* read the config file */ /* read the config file */
while (fgets(buf, sizeof(buf), fp) != NULL) { while (fgets_unlocked(buf, sizeof(buf), fp) != NULL) {
/* skip comments */ /* skip comments */
if (*buf == ';' || *buf == '#') if (*buf == ';' || *buf == '#')
continue; continue;

View File

@ -94,7 +94,7 @@ __get_nprocs ()
string "processor". We don't have to fear extremely long string "processor". We don't have to fear extremely long
lines since the kernel will not generate them. 8192 lines since the kernel will not generate them. 8192
bytes are really enough. */ bytes are really enough. */
while (fgets (buffer, sizeof buffer, fp) != NULL) while (fgets_unlocked (buffer, sizeof buffer, fp) != NULL)
if (strncmp (buffer, "processor", 9) == 0) if (strncmp (buffer, "processor", 9) == 0)
++result; ++result;
@ -141,7 +141,7 @@ phys_pages_info (const char *format)
string "processor". We don't have to fear extremely long string "processor". We don't have to fear extremely long
lines since the kernel will not generate them. 8192 lines since the kernel will not generate them. 8192
bytes are really enough. */ bytes are really enough. */
while (fgets (buffer, sizeof buffer, fp) != NULL) while (fgets_unlocked (buffer, sizeof buffer, fp) != NULL)
if (sscanf (buffer, format, &result) == 1) if (sscanf (buffer, format, &result) == 1)
{ {
result /= (__getpagesize () / 1024); result /= (__getpagesize () / 1024);

View File

@ -1,5 +1,5 @@
/* Convert a string representation of time to a time value. /* Convert a string representation of time to a time value.
Copyright (C) 1997 Free Software Foundation, Inc. Copyright (C) 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997. Contributed by Mark Kettenis <kettenis@phys.uva.nl>, 1997.
@ -145,13 +145,13 @@ __getdate_r (const char *string, struct tm *tp)
if (result && *result == '\0') if (result && *result == '\0')
break; break;
} }
while (!feof (fp)); while (!feof_unlocked (fp));
/* Free the buffer. */ /* Free the buffer. */
free (line); free (line);
/* Check for errors. */ /* Check for errors. */
if (ferror (fp)) if (ferror_unlocked (fp))
{ {
fclose (fp); fclose (fp);
return 5; return 5;