From eec9ca130519196ba4242d3606381c314da83a09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sun, 19 Oct 2025 20:42:21 +0200 Subject: [PATCH] [FREELDR] fs.c: Fix path device name lookup Suppose the list of devices contains, for example listed in this order: `multi(0)disk(0)rdisk(0)partition(1)`, followed by: `multi(0)disk(0)rdisk(0)`, then if someone attempts to open `multi(0)disk(0)rdisk(0)`, the code would erroneously open `multi(0)disk(0)rdisk(0)partition(1)` instead. Device name lookup now verifies that the device name being tested has the same length as the one being opened. Noticed by user "Xen", see: https://reactos.org/forum/viewtopic.php?p=144840#p144840 > Wrong name comparison in ArcOpen (can open "device()partition()" > instead of "device()" that was really requested) --- boot/freeldr/freeldr/lib/fs/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot/freeldr/freeldr/lib/fs/fs.c b/boot/freeldr/freeldr/lib/fs/fs.c index fe640f69a55..1f231c46f85 100644 --- a/boot/freeldr/freeldr/lib/fs/fs.c +++ b/boot/freeldr/freeldr/lib/fs/fs.c @@ -257,7 +257,7 @@ ARC_STATUS ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId) pEntry = pEntry->Flink) { pDevice = CONTAINING_RECORD(pEntry, DEVICE, ListEntry); - if (strncmp(pDevice->DeviceName, DeviceName, Length) == 0) + if ((strlen(pDevice->DeviceName) == Length) && (strncmp(pDevice->DeviceName, DeviceName, Length) == 0)) break; }