diff mbox series

[v2,21/30] libmultipath: allow zero-padded SCSI names in parse_vpd_pg83()

Message ID 20190624092756.7769-23-mwilck@suse.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series multipath-tools: gcc9, VPD parsing, and get_uid fixes | expand

Commit Message

Martin Wilck June 24, 2019, 9:27 a.m. UTC
The spec says that SCSI name strings designator length must be a multiple of
4, and that strings must be zero-terminated and zero-padded.
Fix the returned string length if the VPD input ends with multiple 0-bytes.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/discovery.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 32e3f9d3..3558e559 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -1032,6 +1032,8 @@  parse_vpd_pg83(const unsigned char *in, size_t in_len,
 
 			vpd += 4;
 			len = vpd_len - 4;
+			while (len > 2 && vpd[len - 2] == '\0')
+				--len;
 			if (len > out_len - 1) {
 				condlog(1, "%s: WWID overflow, type 8/%c, %d/%lu bytes required",
 					__func__, out[0], len + 1, out_len);