diff options
author | Ondřej Bílka <neleai@seznam.cz> | 2013-11-07 12:46:57 +0100 |
---|---|---|
committer | Ondřej Bílka <neleai@seznam.cz> | 2013-11-07 12:51:44 +0100 |
commit | e4368156e64e04a204d832351abcb535572eb919 (patch) | |
tree | 764a98186b46f3ef1c611865d092de326fbce675 /nss | |
parent | 8d6bb57c44557c344d56653c3380885bf1dcabd7 (diff) | |
download | glibc-e4368156e64e04a204d832351abcb535572eb919.zip glibc-e4368156e64e04a204d832351abcb535572eb919.tar.gz glibc-e4368156e64e04a204d832351abcb535572eb919.tar.bz2 |
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.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/nss/getent.c b/nss/getent.c index 8a3c864..05ea808 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); |