This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PING][PATCH][BZ #15374] Make getent services compliant with RFC 6335 section 5.1
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Thu, 31 Oct 2013 12:43:19 +0100
- Subject: [PING][PATCH][BZ #15374] Make getent services compliant with RFC 6335 section 5.1
- Authentication-results: sourceware.org; auth=none
- References: <20131020180745 dot GA18200 at domone dot podge>
ping
On Sun, Oct 20, 2013 at 08:07:45PM +0200, OndÅej BÃlka wrote:
> Hi,
>
> >From bugzilla entry "
> RFC 6335 section 5.1 permits service names with leading digits.
> nss/getent.c does not, as they would be treated as port numbers."
>
> I replaced a check there which checks that uses strtol.
>
> OK to commit?
>
> [BZ #15374]
> * nss/getent.c: Recognize services starting with digit.
>
> diff --git a/nss/getent.c b/nss/getent.c
> index 8a3c864..edffc19 100644
> --- a/nss/getent.c
> +++ b/nss/getent.c
> @@ -788,8 +788,11 @@ services_keys (int number, char *key[])
> if (proto != NULL)
> *proto++ = '\0';
>
> - if (isdigit (key[i][0]))
> - serv = getservbyport (htons (atol (key[i])), proto);
> + char *endptr;
> + long port = strtol (key[i], &endptr, 0);
> +
> + if (*endptr == '\0')
> + serv = getservbyport (htons (port), proto);
> else
> serv = getservbyname (key[i], proto);
>
--
Maintenance window broken