Part 2 of bug 187310.. had to commit separately due to local confusion.
Don't let pw crash when give certain input. PR: 187310 Submitted by: Kim Shrier MFC after: 1 week
This commit is contained in:
parent
5691bbf05d
commit
bbd054cb33
@ -425,12 +425,14 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
|
||||
}
|
||||
|
||||
grp = GETGRNAM(a_name->val);
|
||||
if (grp != NULL && *grp->gr_mem == NULL)
|
||||
if (grp != NULL &&
|
||||
(grp->gr_mem == NULL || *grp->gr_mem == NULL))
|
||||
delgrent(GETGRNAM(a_name->val));
|
||||
SETGRENT();
|
||||
while ((grp = GETGRENT()) != NULL) {
|
||||
int i;
|
||||
char group[MAXLOGNAME];
|
||||
if (grp->gr_mem != NULL) {
|
||||
for (i = 0; grp->gr_mem[i] != NULL; i++) {
|
||||
if (!strcmp(grp->gr_mem[i], a_name->val)) {
|
||||
while (grp->gr_mem[i] != NULL) {
|
||||
@ -441,6 +443,7 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ENDGRENT();
|
||||
|
||||
pw_log(cnf, mode, W_USER, "%s(%ld) account removed", a_name->val, (long) uid);
|
||||
@ -908,7 +911,8 @@ pw_gidpolicy(struct userconf * cnf, struct cargs * args, char *nam, gid_t prefer
|
||||
errx(EX_NOUSER, "group `%s' is not defined", a_gid->val);
|
||||
}
|
||||
gid = grp->gr_gid;
|
||||
} else if ((grp = GETGRNAM(nam)) != NULL && grp->gr_mem[0] == NULL) {
|
||||
} else if ((grp = GETGRNAM(nam)) != NULL &&
|
||||
(grp->gr_mem == NULL || grp->gr_mem[0] == NULL)) {
|
||||
gid = grp->gr_gid; /* Already created? Use it anyway... */
|
||||
} else {
|
||||
struct cargs grpargs;
|
||||
@ -1182,6 +1186,7 @@ print_user(struct passwd * pwd, int pretty, int v7)
|
||||
while ((grp=GETGRENT()) != NULL)
|
||||
{
|
||||
int i = 0;
|
||||
if (grp->gr_mem != NULL) {
|
||||
while (grp->gr_mem[i] != NULL)
|
||||
{
|
||||
if (strcmp(grp->gr_mem[i], pwd->pw_name)==0)
|
||||
@ -1192,6 +1197,7 @@ print_user(struct passwd * pwd, int pretty, int v7)
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
ENDGRENT();
|
||||
printf("%s", j ? "\n" : "");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user