summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2023-02-06 12:18:55 -0600
committerDavid Teigland <teigland@redhat.com>2023-02-06 12:24:18 -0600
commitdc99f0def17b936f95c63612a56ae2a6ae81db0e (patch)
tree2c2a52adf69577182257685663385715dc630461 /lib
parent57ad78d4369ee531ab0173b42aa91048eb316353 (diff)
downloadlvm2-dc99f0def17b936f95c63612a56ae2a6ae81db0e.tar.gz
device_id: ignore quotes in device id
A t10 wwid string was found containing a " character which breaks vg metadata parsing. Ignore any quotation marks in device id strings.
Diffstat (limited to 'lib')
-rw-r--r--lib/device/device_id.c6
-rw-r--r--lib/device/parse_vpd.c6
2 files changed, 10 insertions, 2 deletions
diff --git a/lib/device/device_id.c b/lib/device/device_id.c
index 1be6b0787..79da12884 100644
--- a/lib/device/device_id.c
+++ b/lib/device/device_id.c
@@ -438,8 +438,8 @@ int dev_read_sys_wwid(struct cmd_context *cmd, struct device *dev,
if (!ret || !buf[0])
return 0;
- /* in t10 id, replace series of spaces with one _ */
- if (!strncmp(buf, "t10.", 4) && strchr(buf, ' ')) {
+ /* in t10 id, replace characters like space and quote */
+ if (!strncmp(buf, "t10.", 4)) {
if (bufsize < DEV_WWID_SIZE)
return 0;
memcpy(tmpbuf, buf, DEV_WWID_SIZE);
@@ -587,6 +587,8 @@ const char *device_id_system_read(struct cmd_context *cmd, struct device *dev, u
/* wwids are already munged if needed */
if (idtype != DEV_ID_TYPE_SYS_WWID) {
for (i = 0; i < strlen(sysbuf); i++) {
+ if (sysbuf[i] == '"')
+ continue;
if (isblank(sysbuf[i]) || isspace(sysbuf[i]) || iscntrl(sysbuf[i]))
sysbuf[i] = '_';
}
diff --git a/lib/device/parse_vpd.c b/lib/device/parse_vpd.c
index bea8834d4..c1ac974fd 100644
--- a/lib/device/parse_vpd.c
+++ b/lib/device/parse_vpd.c
@@ -53,6 +53,12 @@ int format_t10_id(const unsigned char *in, int in_bytes, unsigned char *out, int
/* skip leading spaces */
if (!retlen && (in[i] == ' '))
continue;
+ /* skip non-ascii non-printable characters */
+ if (!isascii(in[i]) || !isprint(in[i]))
+ continue;
+ /* skip quote */
+ if (in[i] == '"')
+ continue;
/* replace one or more spaces with _ */
if (in[i] == ' ') {
in_space = 1;