* 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:
parent
a1dd26d2d6
commit
d4fc74e43c
@ -1,3 +1,8 @@
|
|||||||
|
2009-03-21 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* lib/sgetpwent.c, lib/sgetgrent.c: Use get_uid and get_gid to
|
||||||
|
validate the UIDs or GIDs instead of atoi/strtol.
|
||||||
|
|
||||||
2009-03-21 Nicolas François <nicolas.francois@centraliens.net>
|
2009-03-21 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* libmisc/get_gid.c, libmisc/get_uid.c, libmisc/Makefile.am,
|
* libmisc/get_gid.c, libmisc/get_uid.c, libmisc/Makefile.am,
|
||||||
|
@ -141,7 +141,9 @@ struct group *sgetgrent (const char *buf)
|
|||||||
}
|
}
|
||||||
grent.gr_name = grpfields[0];
|
grent.gr_name = grpfields[0];
|
||||||
grent.gr_passwd = grpfields[1];
|
grent.gr_passwd = grpfields[1];
|
||||||
grent.gr_gid = atoi (grpfields[2]);
|
if (get_gid (grpfields[2], &grent.gr_gid) == 0) {
|
||||||
|
return (struct group *) 0;
|
||||||
|
}
|
||||||
grent.gr_mem = list (grpfields[3]);
|
grent.gr_mem = list (grpfields[3]);
|
||||||
if (NULL == grent.gr_mem) {
|
if (NULL == grent.gr_mem) {
|
||||||
return (struct group *) 0; /* out of memory */
|
return (struct group *) 0; /* out of memory */
|
||||||
|
@ -108,14 +108,10 @@ struct passwd *sgetpwent (const char *buf)
|
|||||||
|
|
||||||
pwent.pw_name = fields[0];
|
pwent.pw_name = fields[0];
|
||||||
pwent.pw_passwd = fields[1];
|
pwent.pw_passwd = fields[1];
|
||||||
pwent.pw_uid = strtol (fields[2], &ep, 10);
|
if (get_uid (fields[2], &pwent.pw_uid) == 0) {
|
||||||
/* FIXME: (0 == pwent.pw_uid) does not look correct -- nekral */
|
|
||||||
if ((0 == pwent.pw_uid) && ('\0' != *ep)) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* FIXME: (0 == pwent.pw_gid) does not look correct -- nekral */
|
if (get_gid (fields[3], &pwent.pw_gid) == 0) {
|
||||||
pwent.pw_gid = strtol (fields[3], &ep, 10);
|
|
||||||
if ((0 == pwent.pw_gid) && ('\0' != *ep)) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
pwent.pw_gecos = fields[4];
|
pwent.pw_gecos = fields[4];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user