From d1d1c206d6f1d59f978deaec0de7570e1ac063f2 Mon Sep 17 00:00:00 2001 From: drepper Date: Sun, 5 Jul 1998 12:00:27 +0000 Subject: [PATCH] (__getmntent_r): Explicitly lock stream. Use fgets_unlocked. --- misc/mntent_r.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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; } -- 2.11.0