about summary refs log tree commit diff
path: root/nss/getent.c
diff options
context:
space:
mode:
Diffstat (limited to 'nss/getent.c')
-rw-r--r--nss/getent.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/nss/getent.c b/nss/getent.c
index 26df38068a..bcc363dccf 100644
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -206,16 +206,13 @@ group_keys (int number, char *key[])
 
   for (i = 0; i < number; ++i)
     {
-      if (isdigit (key[i][0]))
-	{
-           char *ep;
-           gid_t arg_gid = strtoul (key[i], &ep, 10);
+      errno = 0;
+      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;
-	}
+      if (errno != EINVAL && *key[i] != '\0' && *ep == '\0')
+	/* Valid numeric gid.  */
+	grp = getgrgid (arg_gid);
       else
 	grp = getgrnam (key[i]);
 
@@ -481,16 +478,13 @@ passwd_keys (int number, char *key[])
 
   for (i = 0; i < number; ++i)
     {
-      if (isdigit (key[i][0]))
-        {
-	   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;
-        }
+      errno = 0;
+      char *ep;
+      uid_t arg_uid = strtoul(key[i], &ep, 10);
+
+      if (errno != EINVAL && *key[i] != '\0' && *ep == '\0')
+	/* Valid numeric uid.  */
+	pwd = getpwuid (arg_uid);
       else
 	pwd = getpwnam (key[i]);