From dc99f0def17b936f95c63612a56ae2a6ae81db0e Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mon, 6 Feb 2023 12:18:55 -0600 Subject: 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. --- lib/device/device_id.c | 6 ++++-- lib/device/parse_vpd.c | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'lib') 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; -- cgit v1.2.1