diff --git a/libmisc/prefix_flag.c b/libmisc/prefix_flag.c index 6581235e..8ceffd26 100644 --- a/libmisc/prefix_flag.c +++ b/libmisc/prefix_flag.c @@ -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); diff --git a/src/usermod.c b/src/usermod.c index e571426f..7355ad31 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -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;