Blame SOURCES/0015-Detail.c-do-not-skip-first-character-when-calling-xs.patch

5d5466
From e3615ecb5b6ad8eb408296878aad5628e0e27166 Mon Sep 17 00:00:00 2001
5d5466
From: Coly Li <colyli@suse.de>
5d5466
Date: Tue, 12 Feb 2019 12:53:18 +0800
5d5466
Subject: [RHEL7.7 PATCH 15/24] Detail.c: do not skip first character when
5d5466
 calling xstrdup in Detail()
5d5466
5d5466
'Commit b9c9bd9bacaa ("Detail: ensure --export names are acceptable as
5d5466
shell variables")' duplicates mdi->sys_name to sysdev string by,
5d5466
	char *sysdev = xstrdup(mdi->sys_name + 1);
5d5466
which skips the first character of mdi->sys_name. Then when running
5d5466
mdadm --detail <md device> --export, the output looks like,
5d5466
	MD_DEVICE_ev_sda2_ROLE=1
5d5466
	MD_DEVICE_ev_sda2_DEV=/dev/sda2
5d5466
The first character of md device (between MD_DEVICE and _ROLE/_DEV)
5d5466
is dropped. The expected output should be,
5d5466
	MD_DEVICE_dev_sda2_ROLE=1
5d5466
	MD_DEVICE_dev_sda2_DEV=/dev/sda2
5d5466
5d5466
This patch removes the '+ 1' from calling xstrdup() in Detail(), which
5d5466
gets the dropped first character back.
5d5466
5d5466
Reported-by: Arvin Schnell <aschnell@suse.com>
5d5466
Fixes: b9c9bd9bacaa ("Detail: ensure --export names are acceptable as 4 shell variables")
5d5466
Signed-off-by: Coly Li <colyli@suse.de>
5d5466
Cc: NeilBrown <neilb@suse.com>
5d5466
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
5d5466
---
5d5466
 Detail.c | 2 +-
5d5466
 1 file changed, 1 insertion(+), 1 deletion(-)
5d5466
5d5466
diff --git a/Detail.c b/Detail.c
5d5466
index b3e857a..20ea03a 100644
5d5466
--- a/Detail.c
5d5466
+++ b/Detail.c
5d5466
@@ -284,7 +284,7 @@ int Detail(char *dev, struct context *c)
5d5466
 			struct mdinfo *mdi;
5d5466
 			for (mdi  = sra->devs; mdi; mdi = mdi->next) {
5d5466
 				char *path;
5d5466
-				char *sysdev = xstrdup(mdi->sys_name + 1);
5d5466
+				char *sysdev = xstrdup(mdi->sys_name);
5d5466
 				char *cp;
5d5466
 
5d5466
 				path = map_dev(mdi->disk.major,
5d5466
-- 
5d5466
2.7.5
5d5466