]> git.ipfire.org Git - thirdparty/mdadm.git/commit
Detail.c: do not skip first character when calling xstrdup in Detail()
authorColy Li <colyli@suse.de>
Tue, 12 Feb 2019 04:53:18 +0000 (12:53 +0800)
committerJes Sorensen <jsorensen@fb.com>
Wed, 13 Feb 2019 18:12:50 +0000 (13:12 -0500)
commite3615ecb5b6ad8eb408296878aad5628e0e27166
treeec8033f308012238fef2cfcfbe41e49d0086d3f1
parentebf3be9931f31df54df52b1821479e6a80a4d9c6
Detail.c: do not skip first character when calling xstrdup in Detail()

'Commit b9c9bd9bacaa ("Detail: ensure --export names are acceptable as
shell variables")' duplicates mdi->sys_name to sysdev string by,
char *sysdev = xstrdup(mdi->sys_name + 1);
which skips the first character of mdi->sys_name. Then when running
mdadm --detail <md device> --export, the output looks like,
MD_DEVICE_ev_sda2_ROLE=1
MD_DEVICE_ev_sda2_DEV=/dev/sda2
The first character of md device (between MD_DEVICE and _ROLE/_DEV)
is dropped. The expected output should be,
MD_DEVICE_dev_sda2_ROLE=1
MD_DEVICE_dev_sda2_DEV=/dev/sda2

This patch removes the '+ 1' from calling xstrdup() in Detail(), which
gets the dropped first character back.

Reported-by: Arvin Schnell <aschnell@suse.com>
Fixes: b9c9bd9bacaa ("Detail: ensure --export names are acceptable as 4 shell variables")
Signed-off-by: Coly Li <colyli@suse.de>
Cc: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Detail.c