https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8bb7cd286bc106dd67a869...
commit 8bb7cd286bc106dd67a869e045d589960873bd1b Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Sun Jan 19 23:00:04 2025 +0100 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Tue Jan 21 19:16:01 2025 +0100
[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. --- drivers/storage/mountmgr/device.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/storage/mountmgr/device.c b/drivers/storage/mountmgr/device.c index fdf6af9435b..22710b7b4d7 100644 --- a/drivers/storage/mountmgr/device.c +++ b/drivers/storage/mountmgr/device.c @@ -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; }