summary refs log tree commit diff
path: root/nss
diff options
context:
space:
mode:
authorOndřej Bílka <neleai@seznam.cz>2013-11-07 12:46:57 +0100
committerOndřej Bílka <neleai@seznam.cz>2013-11-07 12:51:44 +0100
commite4368156e64e04a204d832351abcb535572eb919 (patch)
tree764a98186b46f3ef1c611865d092de326fbce675 /nss
parent8d6bb57c44557c344d56653c3380885bf1dcabd7 (diff)
downloadglibc-e4368156e64e04a204d832351abcb535572eb919.tar.gz
glibc-e4368156e64e04a204d832351abcb535572eb919.tar.xz
glibc-e4368156e64e04a204d832351abcb535572eb919.zip
Make getent services compliant with RFC 6335 section 5.1 Fixes bug 15374
The RFC 6335 allows services that start with digit (like 3com-tsmux).
These were parsed as port number which this patch fixes.
Diffstat (limited to 'nss')
-rw-r--r--nss/getent.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/nss/getent.c b/nss/getent.c
index 8a3c864501..05ea80825a 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);