diff options
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); |