From 2da92ac67bc7f664840a21f1d55e87192828ae06 Mon Sep 17 00:00:00 2001 From: Pierre Schweitzer Date: Thu, 17 Oct 2019 22:40:23 +0200 Subject: [PATCH] [MOUNTMGR] QueryPointsFromMemory: take into account the multiple MOUNTMGR_MOUNT_POINT This fixes returning too small structure on an IOCTL_MOUNTMGR_QUERY_POINTS call. The multiple MOUNTMGR_MOUNT_POINT structures were ignored and thus the data of the first one were erased by the multiple structures. MountMgr now returns consistent output on this IOCTL call. --- drivers/filters/mountmgr/point.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/filters/mountmgr/point.c b/drivers/filters/mountmgr/point.c index 26c263eec08..35fe8bb2435 100644 --- a/drivers/filters/mountmgr/point.c +++ b/drivers/filters/mountmgr/point.c @@ -336,9 +336,9 @@ QueryPointsFromMemory(IN PDEVICE_EXTENSION DeviceExtension, MountPoints = (PMOUNTMGR_MOUNT_POINTS)Irp->AssociatedIrp.SystemBuffer; /* Ensure we set output to let user reallocate! */ - MountPoints->Size = sizeof(MOUNTMGR_MOUNT_POINTS) + TotalSize; + MountPoints->Size = sizeof(MOUNTMGR_MOUNT_POINTS) + TotalSymLinks * sizeof(MOUNTMGR_MOUNT_POINT) + TotalSize; MountPoints->NumberOfMountPoints = TotalSymLinks; - Irp->IoStatus.Information = sizeof(MOUNTMGR_MOUNT_POINTS) + TotalSize; + Irp->IoStatus.Information = MountPoints->Size; if (MountPoints->Size > Stack->Parameters.DeviceIoControl.OutputBufferLength) { @@ -353,8 +353,8 @@ QueryPointsFromMemory(IN PDEVICE_EXTENSION DeviceExtension, } /* Now, start putting mount points */ + TotalSize = sizeof(MOUNTMGR_MOUNT_POINTS) + TotalSymLinks * sizeof(MOUNTMGR_MOUNT_POINT); TotalSymLinks = 0; - TotalSize = 0; for (DeviceEntry = DeviceExtension->DeviceListHead.Flink; DeviceEntry != &(DeviceExtension->DeviceListHead); DeviceEntry = DeviceEntry->Flink) @@ -391,16 +391,12 @@ QueryPointsFromMemory(IN PDEVICE_EXTENSION DeviceExtension, { SymlinkInformation = CONTAINING_RECORD(SymlinksEntry, SYMLINK_INFORMATION, SymbolicLinksListEntry); - - MountPoints->MountPoints[TotalSymLinks].SymbolicLinkNameOffset = sizeof(MOUNTMGR_MOUNT_POINTS) + - TotalSize; + MountPoints->MountPoints[TotalSymLinks].SymbolicLinkNameOffset = TotalSize; MountPoints->MountPoints[TotalSymLinks].SymbolicLinkNameLength = SymlinkInformation->Name.Length; - MountPoints->MountPoints[TotalSymLinks].UniqueIdOffset = sizeof(MOUNTMGR_MOUNT_POINTS) + - SymlinkInformation->Name.Length + + MountPoints->MountPoints[TotalSymLinks].UniqueIdOffset = SymlinkInformation->Name.Length + TotalSize; MountPoints->MountPoints[TotalSymLinks].UniqueIdLength = DeviceInformation->UniqueId->UniqueIdLength; - MountPoints->MountPoints[TotalSymLinks].DeviceNameOffset = sizeof(MOUNTMGR_MOUNT_POINTS) + - SymlinkInformation->Name.Length + + MountPoints->MountPoints[TotalSymLinks].DeviceNameOffset = SymlinkInformation->Name.Length + DeviceInformation->UniqueId->UniqueIdLength + TotalSize; MountPoints->MountPoints[TotalSymLinks].DeviceNameLength = DeviceInformation->DeviceName.Length; -- 2.17.1