[MOUNTMGR] Fix three more bugs in MountMgrQueryDosVolumePath() (#6990)

- When trying to find a device, don't fail with STATUS_NOT_FOUND if no
  associated symbolic links are present. Instead, that test was wrong,
  and should go out of the search loop to do the drive-letter processing.

  Addendum to commit f9f5a78715.

- In addition, when using the associated-device method, fix the list
  used to retrieve the corresponding device.

- In the TryWithVolumeName: block, reset DeviceString to NULL after
  freeing, so that we can correctly fail with STATUS_NOT_FOUND if no
  suitable device was found, before initializing the output data.
This commit is contained in:
Hermès Bélusca-Maïto 2025-01-19 23:00:04 +01:00
parent 28c3533d11
commit 8bb7cd286b
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -887,20 +887,16 @@ MountMgrQueryDosVolumePath(IN PDEVICE_EXTENSION DeviceExtension,
}
}
/* We didn't find, break */
if (SymlinksEntry == &(DeviceInformation->SymbolicLinksListHead))
{
return STATUS_NOT_FOUND;
}
/* If we've found a device via drive letter, do default processing */
if (SymlinksEntry != &(DeviceInformation->SymbolicLinksListHead))
break;
/* It doesn't have associated device, go to fallback method */
/* If it doesn't have an associated device, go to fallback method */
if (IsListEmpty(&DeviceInformation->AssociatedDevicesHead))
{
goto TryWithVolumeName;
}
/* Create a string with the information about the device */
AssociatedDevice = CONTAINING_RECORD(&(DeviceInformation->SymbolicLinksListHead), ASSOCIATED_DEVICE_ENTRY, AssociatedDevicesEntry);
AssociatedDevice = CONTAINING_RECORD(&(DeviceInformation->AssociatedDevicesHead), ASSOCIATED_DEVICE_ENTRY, AssociatedDevicesEntry);
OldLength = DeviceLength;
OldBuffer = DeviceString;
DeviceLength += AssociatedDevice->String.Length;
@ -967,6 +963,7 @@ TryWithVolumeName:
if (DeviceString)
{
FreePool(DeviceString);
DeviceString = NULL;
DeviceLength = 0;
}