diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/device/device_id.c | 6 | ||||
-rw-r--r-- | lib/device/parse_vpd.c | 6 |
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; |