about summary refs log tree commit diff
path: root/nss
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-08-06 09:25:59 +0000
committerUlrich Drepper <drepper@redhat.com>2004-08-06 09:25:59 +0000
commit9030e7c44aa75345336673c0252974ead4eb8364 (patch)
treec898cc7e9f7f6e5559cacaa0c1dc78893628bd54 /nss
parenta55bda85baca5feee69b7bc01b9c76f89a6347dd (diff)
downloadglibc-9030e7c44aa75345336673c0252974ead4eb8364.tar.gz
glibc-9030e7c44aa75345336673c0252974ead4eb8364.tar.xz
glibc-9030e7c44aa75345336673c0252974ead4eb8364.zip
Update.
2004-07-30  Guido Guenther  <agx@sigxcpu.org>

	* nss/getent.c (passwd_keys): Use strtoul instead of isdigit to
	test if the key is numeric or not.
	(group_keys): Likewise.
Diffstat (limited to 'nss')
-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]);