libmultipath: allow zero-padded SCSI names in parse_vpd_pg83()
authorMartin Wilck <mwilck@suse.com>
Mon, 24 Jun 2019 09:27:47 +0000 (11:27 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Wed, 3 Jul 2019 06:31:37 +0000 (08:31 +0200)
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

index 32e3f9d..3558e55 100644 (file)
@@ -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);