diff options
Diffstat (limited to 'nss/getent.c')
-rw-r--r-- | nss/getent.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/nss/getent.c b/nss/getent.c index 1ddd67ad23..7a755f8b1c 100644 --- a/nss/getent.c +++ b/nss/getent.c @@ -207,7 +207,15 @@ group_keys (int number, char *key[]) for (i = 0; i < number; ++i) { if (isdigit (key[i][0])) - grp = getgrgid (atol (key[i])); + { + char *ep; + gid_t arg_gid = strtoul (key[i], &ep, 10); + + if (*key[i] != '\0' && *ep == '\0') /* valid numeric uid */ + grp = getgrgid (arg_gid); + else + grp = NULL; + } else grp = getgrnam (key[i]); @@ -404,7 +412,15 @@ passwd_keys (int number, char *key[]) for (i = 0; i < number; ++i) { if (isdigit (key[i][0])) - pwd = getpwuid (atol (key[i])); + { + char *ep; + uid_t arg_uid = strtoul (key[i], &ep, 10); + + if (*key[i] != '\0' && *ep == '\0') /* valid numeric uid */ + pwd = getpwuid (arg_uid); + else + pwd = NULL; + } else pwd = getpwnam (key[i]); |