https://git.reactos.org/?p=reactos.git;a=commitdiff;h=293f8230536c79128f380…
commit 293f8230536c79128f380f2dd69d2c684b4167f9
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Thu Jun 17 16:33:33 2021 +0200
Commit: Jérôme Gardou <zefklop(a)users.noreply.github.com>
CommitDate: Mon Jun 28 10:20:57 2021 +0200
[NTOS:IO] Check RtlAnsiStringToUnicodeString return value when initializing ramdisk
CORE-17637
---
ntoskrnl/include/internal/io.h | 4 ++++
ntoskrnl/io/iomgr/ramdisk.c | 10 +++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/ntoskrnl/include/internal/io.h b/ntoskrnl/include/internal/io.h
index 095d63bbefc..46470e9835c 100644
--- a/ntoskrnl/include/internal/io.h
+++ b/ntoskrnl/include/internal/io.h
@@ -80,6 +80,10 @@
// Unable to create symbolic link pointing to the RAM disk device
//
#define RD_SYMLINK_CREATE_FAILED 5
+//
+// Unable to create system root path when creating the RAM disk
+//
+#define RD_SYSROOT_INIT_FAILED 6
//
// Max traversal of reparse points for a single open in IoParseDevice
diff --git a/ntoskrnl/io/iomgr/ramdisk.c b/ntoskrnl/io/iomgr/ramdisk.c
index b959e964fff..d83bb8050cb 100644
--- a/ntoskrnl/io/iomgr/ramdisk.c
+++ b/ntoskrnl/io/iomgr/ramdisk.c
@@ -262,7 +262,15 @@ IopStartRamdisk(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
RtlInitEmptyUnicodeString(&NtSystemRoot,
SharedUserData->NtSystemRoot,
sizeof(SharedUserData->NtSystemRoot));
- RtlAnsiStringToUnicodeString(&NtSystemRoot, &AnsiPath, FALSE);
+ Status = RtlAnsiStringToUnicodeString(&NtSystemRoot, &AnsiPath, FALSE);
+ if (!NT_SUCCESS(Status))
+ {
+ KeBugCheckEx(RAMDISK_BOOT_INITIALIZATION_FAILED,
+ RD_SYSROOT_INIT_FAILED,
+ Status,
+ 0,
+ 0);
+ }
IoCreateSymbolicLink(&DriveLetter, &DeviceString);
}