diff options
author | Ulrich Drepper <drepper@redhat.com> | 2004-08-06 09:25:59 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2004-08-06 09:25:59 +0000 |
commit | 9030e7c44aa75345336673c0252974ead4eb8364 (patch) | |
tree | c898cc7e9f7f6e5559cacaa0c1dc78893628bd54 /nss/getent.c | |
parent | a55bda85baca5feee69b7bc01b9c76f89a6347dd (diff) | |
download | glibc-9030e7c44aa75345336673c0252974ead4eb8364.zip glibc-9030e7c44aa75345336673c0252974ead4eb8364.tar.gz glibc-9030e7c44aa75345336673c0252974ead4eb8364.tar.bz2 |
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/getent.c')
-rw-r--r-- | nss/getent.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/nss/getent.c b/nss/getent.c index 26df380..bcc363d 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]); |