Blame SOURCES/shadow-4.6-usermod-crash.patch

e5cfd7
diff -up shadow-4.6/libmisc/prefix_flag.c.usermod-crash shadow-4.6/libmisc/prefix_flag.c
e5cfd7
--- shadow-4.6/libmisc/prefix_flag.c.usermod-crash	2018-04-29 18:42:37.000000000 +0200
e5cfd7
+++ shadow-4.6/libmisc/prefix_flag.c	2018-05-28 15:14:10.642302440 +0200
e5cfd7
@@ -319,6 +319,7 @@ extern struct group *prefix_getgr_nam_gi
e5cfd7
 {
e5cfd7
 	long long int gid;
e5cfd7
 	char *endptr;
e5cfd7
+	struct group *g;
e5cfd7
 
e5cfd7
 	if (NULL == grname) {
e5cfd7
 		return NULL;
e5cfd7
@@ -333,7 +334,8 @@ extern struct group *prefix_getgr_nam_gi
e5cfd7
 	    	&& (gid == (gid_t)gid)) {
e5cfd7
 			return prefix_getgrgid ((gid_t) gid);
e5cfd7
 		}
e5cfd7
-		return prefix_getgrnam (grname);
e5cfd7
+		g = prefix_getgrnam (grname);
e5cfd7
+		return g ? __gr_dup(g) : NULL;
e5cfd7
 	}
e5cfd7
 	else
e5cfd7
 		return getgr_nam_gid(grname);
e5cfd7
diff -up shadow-4.6/src/usermod.c.usermod-crash shadow-4.6/src/usermod.c
e5cfd7
--- shadow-4.6/src/usermod.c.usermod-crash	2018-05-28 15:12:37.920332763 +0200
e5cfd7
+++ shadow-4.6/src/usermod.c	2018-05-28 15:15:50.337422470 +0200
e5cfd7
@@ -1276,11 +1276,13 @@ static void process_flags (int argc, cha
e5cfd7
 		prefix_user_home = xmalloc(len);
e5cfd7
 		wlen = snprintf(prefix_user_home, len, "%s/%s", prefix, user_home);
e5cfd7
 		assert (wlen == (int) len -1);
e5cfd7
+		if (user_newhome) {
e5cfd7
+			len = strlen(prefix) + strlen(user_newhome) + 2;
e5cfd7
+			prefix_user_newhome = xmalloc(len);
e5cfd7
+			wlen = snprintf(prefix_user_newhome, len, "%s/%s", prefix, user_newhome);
e5cfd7
+			assert (wlen == (int) len -1);
e5cfd7
+		}
e5cfd7
 
e5cfd7
-		len = strlen(prefix) + strlen(user_newhome) + 2;
e5cfd7
-		prefix_user_newhome = xmalloc(len);
e5cfd7
-		wlen = snprintf(prefix_user_newhome, len, "%s/%s", prefix, user_newhome);
e5cfd7
-		assert (wlen == (int) len -1);
e5cfd7
 	}
e5cfd7
 	else {
e5cfd7
 		prefix_user_home = user_home;