]> xenbits.xensource.com Git - pvdrivers/win/xenvbd.git/commitdiff
Don't include null terminator in synthesized VendorId identifier
authorOwen Smith <owen.smith@citrix.com>
Mon, 3 Oct 2016 07:31:44 +0000 (08:31 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Mon, 3 Oct 2016 07:33:09 +0000 (08:33 +0100)
The VendorId identifier on SCSI page 83 is 16 bytes long (+header).
When synthesizing the inquiry data, either by global flag, or missing
xenstore data (sm-data/scsi/0x12/0x83), the NULL terminator on the
VendorId should not be included in the field. When this happens, any
query will decode 3 identifiers (VendorId, EUI64, VendorSpecific) instead
of the intended 2 (VendorId, VendorSpecific). This breaks the XenServer
VSS provider that uses the VendorSpecific identifier to retrieve the
vdi-uuid. This is only an issue when the inquiry data is synthesized and
additional identifiers are required, which is not a common use case.

Signed-off-by: Owen Smith <owen.smith@citrix.com>
src/xenvbd/pdoinquiry.c

index be7dd844115ce13a5f5ea18554f0c658e8b4dada..4460f3dc583e09d3736df60584f827f546446cb2 100644 (file)
@@ -42,7 +42,7 @@
 #define GUID_LENGTH     36 
 
 // 00 00 00 00 00 00 00 00 "XENSRC  00000000"
-#define PAGE83_MIN_SIZE (4 + 4 + 16 + 1)
+#define PAGE83_MIN_SIZE (4 + 4 + 16)
 
 // 00 00 00 00 + GUID_LENGTH
 #define VDI_ID_LENGTH   (4 + GUID_LENGTH)
@@ -331,13 +331,14 @@ __HandlePage83(
     PCHAR   Data = (PCHAR)Srb->DataBuffer;
     ULONG   Length = Srb->DataTransferLength;
 
-       RtlZeroMemory(Data, Length);
-       if (DriverParameters.SynthesizeInquiry ||
+    RtlZeroMemory(Data, Length);
+    if (DriverParameters.SynthesizeInquiry ||
         Inquiry == NULL || 
         Inquiry->Page83.Data == NULL || 
         Inquiry->Page83.Length == 0) {
         // generate the id page data
         PVPD_IDENTIFICATION_DESCRIPTOR  Id;
+        CHAR    Buffer[17];
 
         if (Length < PAGE83_MIN_SIZE)
             return FALSE;
@@ -349,7 +350,8 @@ __HandlePage83(
         Id->CodeSet             = VpdCodeSetAscii;
         Id->IdentifierType      = VpdIdentifierTypeVendorId;
         Id->IdentifierLength    = 16;
-        (VOID) RtlStringCchPrintfA((PCHAR)Id->Identifier, 17, "XENSRC  %08u", TargetId);
+        (VOID)RtlStringCchPrintfA(Buffer, 17, "XENSRC  %08u", TargetId);
+        RtlCopyMemory((PCHAR)Id->Identifier, Buffer, 16);
 
         Verbose("Target[%u] : INQUIRY Using Fake Page83 Data\n", TargetId);