[PATCH v1.2][BZ #15374] Make getent services compliant with RFC 6335 section 5.1
Ondřej Bílka
neleai@seznam.cz
Wed Nov 6 10:33:00 GMT 2013
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);
More information about the Libc-alpha
mailing list