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

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