This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[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: Sun, 20 Oct 2013 20:07:45 +0200
- Subject: [PATCH][BZ #15374] Make getent services compliant with RFC 6335 section 5.1
- Authentication-results: sourceware.org; auth=none
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);