From: Owen Smith Date: Mon, 3 Oct 2016 07:31:44 +0000 (+0100) Subject: Don't include null terminator in synthesized VendorId identifier X-Git-Tag: 8.2.0-rc1~8 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c460f91a34adcd9fd70b5208f36eb8eb8f64ff53;p=pvdrivers%2Fwin%2Fxenvbd.git Don't include null terminator in synthesized VendorId identifier 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 --- diff --git a/src/xenvbd/pdoinquiry.c b/src/xenvbd/pdoinquiry.c index be7dd84..4460f3d 100644 --- a/src/xenvbd/pdoinquiry.c +++ b/src/xenvbd/pdoinquiry.c @@ -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);