Windows: Add checks on IOCTL_DISK_GET_DRIVE_LAYOUT_EX response to make Coverity happy.

This commit is contained in:
Mounir IDRASSI 2017-06-11 14:38:30 +02:00
parent 1662abb707
commit 70d083bfb2
No known key found for this signature in database
GPG key ID: DD0C382D5FCFB8FC

View file

@ -11995,9 +11995,12 @@ void UpdateMountableHostDeviceList ()
(LPVOID) buffer.data(), (LPVOID) buffer.data(),
(DWORD) buffer.size(), (DWORD) buffer.size(),
(LPDWORD) &bytesReturned, (LPDWORD) &bytesReturned,
NULL)) NULL) && (bytesReturned >= sizeof (DRIVE_LAYOUT_INFORMATION_EX)))
{ {
PDRIVE_LAYOUT_INFORMATION_EX layout = (PDRIVE_LAYOUT_INFORMATION_EX) buffer.data(); PDRIVE_LAYOUT_INFORMATION_EX layout = (PDRIVE_LAYOUT_INFORMATION_EX) buffer.data();
// sanity checks
if (layout->PartitionCount <= 256)
{
for (DWORD i = 0; i < layout->PartitionCount; i++) for (DWORD i = 0; i < layout->PartitionCount; i++)
{ {
if (layout->PartitionEntry[i].PartitionStyle == PARTITION_STYLE_MBR) if (layout->PartitionEntry[i].PartitionStyle == PARTITION_STYLE_MBR)
@ -12054,6 +12057,7 @@ void UpdateMountableHostDeviceList ()
} }
} }
} }
}
if (bIsDynamic) if (bIsDynamic)
dynamicVolumesPresent = true; dynamicVolumesPresent = true;