https://git.reactos.org/?p=reactos.git;a=commitdiff;h=06bff99edbcc87d1e54ec3...
commit 06bff99edbcc87d1e54ec3bb2017588c187cacee Author: Victor Perevertkin victor.perevertkin@reactos.org AuthorDate: Mon Jan 4 17:19:12 2021 +0300 Commit: Victor Perevertkin victor.perevertkin@reactos.org CommitDate: Mon Jan 4 17:19:12 2021 +0300
[I8042PRT][RAMDISK] Fix usage of the RegistryPath in DriverEntry
We can't rely on it being zero-terminated, so ensure that it's duplicated first before usage in RtlQueryRegistryValues --- drivers/input/i8042prt/i8042prt.c | 2 +- drivers/storage/class/ramdisk/ramdisk.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/input/i8042prt/i8042prt.c b/drivers/input/i8042prt/i8042prt.c index 879c231d80f..67106a6e70c 100644 --- a/drivers/input/i8042prt/i8042prt.c +++ b/drivers/input/i8042prt/i8042prt.c @@ -511,7 +511,7 @@ DriverEntry( return Status; }
- Status = ReadRegistryEntries(RegistryPath, &DriverExtension->Port.Settings); + Status = ReadRegistryEntries(&DriverExtension->RegistryPath, &DriverExtension->Port.Settings); if (!NT_SUCCESS(Status)) { WARN_(I8042PRT, "ReadRegistryEntries() failed with status 0x%08lx\n", Status); diff --git a/drivers/storage/class/ramdisk/ramdisk.c b/drivers/storage/class/ramdisk/ramdisk.c index 987d0ffc6fd..8a05a7065af 100644 --- a/drivers/storage/class/ramdisk/ramdisk.c +++ b/drivers/storage/class/ramdisk/ramdisk.c @@ -2419,18 +2419,20 @@ DriverEntry(IN PDRIVER_OBJECT DriverObject, NTSTATUS Status; DPRINT("RAM Disk Driver Initialized\n");
- /* Query ramdisk parameters */ - QueryParameters(RegistryPath); - /* Save the registry path */ - DriverRegistryPath = *RegistryPath; + DriverRegistryPath.MaximumLength = RegistryPath->Length + sizeof(UNICODE_NULL); DriverRegistryPath.Buffer = ExAllocatePoolWithTag(PagedPool, - RegistryPath->Length + - sizeof(UNICODE_NULL), + DriverRegistryPath.MaximumLength, 'dmaR'); - if (!DriverRegistryPath.Buffer) return STATUS_INSUFFICIENT_RESOURCES; + if (!DriverRegistryPath.Buffer) + { + return STATUS_INSUFFICIENT_RESOURCES; + } RtlCopyUnicodeString(&DriverRegistryPath, RegistryPath);
+ /* Query ramdisk parameters */ + QueryParameters(&DriverRegistryPath); + /* Set device routines */ DriverObject->MajorFunction[IRP_MJ_CREATE] = RamdiskOpenClose; DriverObject->MajorFunction[IRP_MJ_CLOSE] = RamdiskOpenClose;