From 9246b663b28ec1dd97e6c162c90d4ad543344bee Mon Sep 17 00:00:00 2001 From: Packit Service Date: Mar 24 2021 01:31:52 +0000 Subject: Apply patch glibc-rh1743445-1.patch patch_name: glibc-rh1743445-1.patch present_in_specfile: true location_in_specfile: 266 --- diff --git a/misc/mntent_r.c b/misc/mntent_r.c index 7a82658..7bb224f 100644 --- a/misc/mntent_r.c +++ b/misc/mntent_r.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -112,26 +113,18 @@ decode_name (char *buf) return buf; } - -/* Read one mount table entry from STREAM. Returns a pointer to storage - reused on the next call, or null for EOF or error (use feof/ferror to - check). */ -struct mntent * -__getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz) +static bool +get_mnt_entry (FILE *stream, struct mntent *mp, char *buffer, int bufsiz) { char *cp; char *head; - flockfile (stream); do { char *end_ptr; if (__fgets_unlocked (buffer, bufsiz, stream) == NULL) - { - funlockfile (stream); - return NULL; - } + return false; end_ptr = strchr (buffer, '\n'); if (end_ptr != NULL) /* chop newline */ @@ -179,9 +172,40 @@ __getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz) case 2: break; } + + return true; +} + +/* Read one mount table entry from STREAM. Returns a pointer to storage + reused on the next call, or null for EOF or error (use feof/ferror to + check). */ +struct mntent * +__getmntent_r (FILE *stream, struct mntent *mp, char *buffer, int bufsiz) +{ + struct mntent *result; + + flockfile (stream); + while (true) + if (get_mnt_entry (stream, mp, buffer, bufsiz)) + { + /* If the file system is autofs look for a mount option hint + ("ignore") to skip the entry. */ + if (strcmp (mp->mnt_type, "autofs") == 0 && __hasmntopt (mp, "ignore")) + memset (mp, 0, sizeof (*mp)); + else + { + result = mp; + break; + } + } + else + { + result = NULL; + break; + } funlockfile (stream); - return mp; + return result; } libc_hidden_def (__getmntent_r) weak_alias (__getmntent_r, getmntent_r)