aboutsummaryrefslogtreecommitdiff
path: root/gshadow/fgetsgent_r.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2020-07-16 17:31:20 +0200
committerFlorian Weimer <fweimer@redhat.com>2020-07-21 07:34:25 +0200
commit2add4235ef674988948155f9a8f60a8c7b09bcff (patch)
treefc0632d81e186958b2fc091b0a2f2fe25e5c5720 /gshadow/fgetsgent_r.c
parent4f62a21d0ed19ff29bba704167179b862140d011 (diff)
downloadglibc-2add4235ef674988948155f9a8f60a8c7b09bcff.tar
glibc-2add4235ef674988948155f9a8f60a8c7b09bcff.tar.gz
glibc-2add4235ef674988948155f9a8f60a8c7b09bcff.tar.bz2
glibc-2add4235ef674988948155f9a8f60a8c7b09bcff.zip
gshadow: Implement fgetsgent_r using __nss_fgetent_r (bug 20338)
Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'gshadow/fgetsgent_r.c')
-rw-r--r--gshadow/fgetsgent_r.c41
1 files changed, 6 insertions, 35 deletions
diff --git a/gshadow/fgetsgent_r.c b/gshadow/fgetsgent_r.c
index a7a1860c76..218206b4ac 100644
--- a/gshadow/fgetsgent_r.c
+++ b/gshadow/fgetsgent_r.c
@@ -36,40 +36,11 @@ int
__fgetsgent_r (FILE *stream, struct sgrp *resbuf, char *buffer, size_t buflen,
struct sgrp **result)
{
- char *p;
-
- _IO_flockfile (stream);
- do
- {
- buffer[buflen - 1] = '\xff';
- p = fgets_unlocked (buffer, buflen, stream);
- if (p == NULL && feof_unlocked (stream))
- {
- _IO_funlockfile (stream);
- *result = NULL;
- __set_errno (ENOENT);
- return errno;
- }
- if (p == NULL || buffer[buflen - 1] != '\xff')
- {
- _IO_funlockfile (stream);
- *result = NULL;
- __set_errno (ERANGE);
- return errno;
- }
-
- /* Skip leading blanks. */
- while (isspace (*p))
- ++p;
- } while (*p == '\0' || *p == '#' /* Ignore empty and comment lines. */
- /* Parse the line. If it is invalid, loop to
- get the next line of the file to parse. */
- || ! parse_line (buffer, (void *) resbuf, (void *) buffer, buflen,
- &errno));
-
- _IO_funlockfile (stream);
-
- *result = resbuf;
- return 0;
+ int ret = __nss_fgetent_r (stream, resbuf, buffer, buflen, parse_line);
+ if (ret == 0)
+ *result = resbuf;
+ else
+ *result = NULL;
+ return ret;
}
weak_alias (__fgetsgent_r, fgetsgent_r)