This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[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:31:15 +0100
- Subject: [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>
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?
[BZ #15374]
* nss/getent.c: 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, 0);
+
+ if (isdigit (key[i][0]) && *endptr == '\0'
+ && 0 <= port && port <= 65535)
+ serv = getservbyport (htons (port), proto);
else
serv = getservbyname (key[i], proto);