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

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