From: Carlos O'Donell <carlos@redhat.com>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH 07/11] grp: Implement fgetgrent_r using __nss_fgetent_r
Date: Mon, 20 Jul 2020 23:28:02 -0400 [thread overview]
Message-ID: <1fa042ed-e8b2-c267-e9dd-21f5bc7304af@redhat.com> (raw)
In-Reply-To: <87552a25db51905c292fa203e99c2184969e1c52.1594974444.git.fweimer@redhat.com>
On 7/17/20 4:30 AM, Florian Weimer via Libc-alpha wrote:
OK for 2.32. Further cleanup of implmenetations using __nss_fgetent_r.
Tested-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> ---
> grp/fgetgrent_r.c | 54 ++++++-----------------------------------------
> 1 file changed, 6 insertions(+), 48 deletions(-)
>
> diff --git a/grp/fgetgrent_r.c b/grp/fgetgrent_r.c
> index 03daf4f295..b598584830 100644
> --- a/grp/fgetgrent_r.c
> +++ b/grp/fgetgrent_r.c
> @@ -20,10 +20,6 @@
> #include <grp.h>
> #include <stdio.h>
>
> -#include <libio/iolibio.h>
> -#define flockfile(s) _IO_flockfile (s)
> -#define funlockfile(s) _IO_funlockfile (s)
> -
> /* Define a line parsing function using the common code
> used in the nss_files module. */
>
> @@ -59,49 +55,11 @@ int
> __fgetgrent_r (FILE *stream, struct group *resbuf, char *buffer, size_t buflen,
> struct group **result)
> {
> - char *p;
> - int parse_result;
> -
> - flockfile (stream);
> - do
> - {
> - buffer[buflen - 1] = '\xff';
> - p = fgets_unlocked (buffer, buflen, stream);
> - if (__builtin_expect (p == NULL, 0) && feof_unlocked (stream))
> - {
> - funlockfile (stream);
> - *result = NULL;
> - __set_errno (ENOENT);
> - return errno;
> - }
> - if (__builtin_expect (p == NULL, 0) || buffer[buflen - 1] != '\xff')
> - {
> - 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_result = parse_line (p, resbuf,
> - (void *) buffer, buflen,
> - &errno)));
> -
> - funlockfile (stream);
> -
> - if (__builtin_expect (parse_result, 0) == -1)
> - {
> - /* The parser ran out of space. */
> - *result = NULL;
> - return errno;
> - }
> -
> - *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 (__fgetgrent_r, fgetgrent_r)
>
--
Cheers,
Carlos.
next prev parent reply other threads:[~2020-07-21 3:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-17 8:29 [PATCH 00/11] Fix fgetsgent_r data corruption bug (20338) Florian Weimer
2020-07-17 8:30 ` [PATCH 01/11] nss_files: Consolidate file opening in __nss_files_fopen Florian Weimer
2020-07-21 3:27 ` Carlos O'Donell
2020-07-17 8:30 ` [PATCH 02/11] nss_compat: Do not use mmap to read database files (bug 26258) Florian Weimer
2020-07-21 3:27 ` Carlos O'Donell
2020-07-17 8:30 ` [PATCH 03/11] nss_files: Consolidate line parse declarations in <nss_files.h> Florian Weimer
2020-07-21 3:27 ` Carlos O'Donell
2020-07-17 8:30 ` [PATCH 04/11] nss_files: Use generic result pointer in parse_line Florian Weimer
2020-07-21 3:27 ` Carlos O'Donell
2020-07-17 8:30 ` [PATCH 05/11] libio: Add fseterr_unlocked for internal use Florian Weimer
2020-07-21 3:27 ` Carlos O'Donell
2020-07-17 8:30 ` [PATCH 06/11] nss: Add __nss_fgetent_r Florian Weimer
2020-07-21 3:27 ` Carlos O'Donell
2020-07-17 8:30 ` [PATCH 07/11] grp: Implement fgetgrent_r using __nss_fgetent_r Florian Weimer
2020-07-21 3:28 ` Carlos O'Donell [this message]
2020-07-17 8:30 ` [PATCH 08/11] gshadow: Implement fgetsgent_r using __nss_fgetent_r (bug 20338) Florian Weimer
2020-07-21 3:28 ` Carlos O'Donell
2020-07-17 8:30 ` [PATCH 09/11] pwd: Implement fgetpwent_r using __nss_fgetent_r Florian Weimer
2020-07-21 3:28 ` Carlos O'Donell
2020-07-17 8:30 ` [PATCH 10/11] shadow: Implement fgetspent_r " Florian Weimer
2020-07-21 3:28 ` Carlos O'Donell
2020-07-17 8:31 ` [PATCH 11/11] libio: Remove __libc_readline_unlocked Florian Weimer
2020-07-21 3:28 ` Carlos O'Donell
2020-07-21 3:27 ` [PATCH 00/11] Fix fgetsgent_r data corruption bug (20338) Carlos O'Donell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1fa042ed-e8b2-c267-e9dd-21f5bc7304af@redhat.com \
--to=carlos@redhat.com \
--cc=fweimer@redhat.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).