Skip to content

Commit eec9ca1

Browse files
committed
[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)
1 parent ad10c08 commit eec9ca1

File tree

1 file changed

+1
-1
lines changed
  • boot/freeldr/freeldr/lib/fs

1 file changed

+1
-1
lines changed

boot/freeldr/freeldr/lib/fs/fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ ARC_STATUS ArcOpen(CHAR* Path, OPENMODE OpenMode, ULONG* FileId)
257257
pEntry = pEntry->Flink)
258258
{
259259
pDevice = CONTAINING_RECORD(pEntry, DEVICE, ListEntry);
260-
if (strncmp(pDevice->DeviceName, DeviceName, Length) == 0)
260+
if ((strlen(pDevice->DeviceName) == Length) && (strncmp(pDevice->DeviceName, DeviceName, Length) == 0))
261261
break;
262262
}
263263

0 commit comments

Comments
 (0)