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

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