dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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