* lib/sgetpwent.c, lib/sgetgrent.c: Use get_uid and get_gid to

validate the UIDs or GIDs instead of atoi/strtol.
This commit is contained in:
nekral-guest
2009-03-21 20:29:58 +00:00
parent a1dd26d2d6
commit d4fc74e43c
3 changed files with 10 additions and 7 deletions

View File

@@ -108,14 +108,10 @@ struct passwd *sgetpwent (const char *buf)
pwent.pw_name = fields[0];
pwent.pw_passwd = fields[1];
pwent.pw_uid = strtol (fields[2], &ep, 10);
/* FIXME: (0 == pwent.pw_uid) does not look correct -- nekral */
if ((0 == pwent.pw_uid) && ('\0' != *ep)) {
if (get_uid (fields[2], &pwent.pw_uid) == 0) {
return NULL;
}
/* FIXME: (0 == pwent.pw_gid) does not look correct -- nekral */
pwent.pw_gid = strtol (fields[3], &ep, 10);
if ((0 == pwent.pw_gid) && ('\0' != *ep)) {
if (get_gid (fields[3], &pwent.pw_gid) == 0) {
return NULL;
}
pwent.pw_gecos = fields[4];