This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v1.2][BZ #15374] Make getent services compliant with RFC 6335 section 5.1
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Andreas Schwab <schwab at linux-m68k dot org>
- Cc: Roland McGrath <roland at hack dot frob dot com>, Florian Weimer <fweimer at redhat dot com>, libc-alpha at sourceware dot org
- Date: Wed, 6 Nov 2013 11:33:36 +0100
- Subject: Re: [PATCH v1.2][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> <527256A2 dot 40902 at redhat dot com> <20131031133244 dot GA19495 at domone dot podge> <52725CB7 dot 30300 at redhat dot com> <20131031150144 dot GA20903 at domone dot podge> <20131031202848 dot 6F4B274699 at topped-with-meat dot com> <20131031205513 dot GB30820 at domone dot podge> <877gcs1r6z dot fsf at igel dot home> <20131106103115 dot GA8181 at domone dot podge>
On Wed, Nov 06, 2013 at 11:31:15AM +0100, OndÅej BÃlka wrote:
> On Fri, Nov 01, 2013 at 09:06:44AM +0100, Andreas Schwab wrote:
> > OndÅej BÃlka <neleai@seznam.cz> writes:
> >
> > > User still can specify -0 to get port 0 which is bit questionable.
> >
> > Don't remove the isdigit check.
> >
> > Andreas.
> >
> OK now?
this one.
[BZ #15374]
* nss/getent.c (services_keys): Recognize services starting with digit.
diff --git a/nss/getent.c b/nss/getent.c
index 8a3c864..e905ec5 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -788,8 +788,12 @@ 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, 10);
+
+ if (isdigit (key[i][0]) && *endptr == '\0'
+ && 0 <= port && port <= 65535)
+ serv = getservbyport (htons (port), proto);
else
serv = getservbyname (key[i], proto);