Fix usermod crash
Return newly allocated pointers when the caller will free them. Closes #110
This commit is contained in:
parent
f50603a5fc
commit
73a876a056
@ -333,7 +333,7 @@ extern struct group *prefix_getgr_nam_gid(const char *grname)
|
||||
&& (gid == (gid_t)gid)) {
|
||||
return prefix_getgrgid ((gid_t) gid);
|
||||
}
|
||||
return prefix_getgrnam (grname);
|
||||
return __gr_dup(prefix_getgrnam (grname));
|
||||
}
|
||||
else
|
||||
return getgr_nam_gid(grname);
|
||||
|
@ -1251,11 +1251,13 @@ static void process_flags (int argc, char **argv)
|
||||
prefix_user_home = xmalloc(len);
|
||||
wlen = snprintf(prefix_user_home, len, "%s/%s", prefix, user_home);
|
||||
assert (wlen == (int) len -1);
|
||||
if (user_newhome) {
|
||||
len = strlen(prefix) + strlen(user_newhome) + 2;
|
||||
prefix_user_newhome = xmalloc(len);
|
||||
wlen = snprintf(prefix_user_newhome, len, "%s/%s", prefix, user_newhome);
|
||||
assert (wlen == (int) len -1);
|
||||
}
|
||||
|
||||
len = strlen(prefix) + strlen(user_newhome) + 2;
|
||||
prefix_user_newhome = xmalloc(len);
|
||||
wlen = snprintf(prefix_user_newhome, len, "%s/%s", prefix, user_newhome);
|
||||
assert (wlen == (int) len -1);
|
||||
}
|
||||
else {
|
||||
prefix_user_home = user_home;
|
||||
|
Loading…
Reference in New Issue
Block a user