[FREELDR] xboxmem: Fix array out-of-bounds access (#1775)
authorStanislav Motylkov <x86corez@gmail.com>
Wed, 7 Aug 2019 10:06:37 +0000 (13:06 +0300)
committerHermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
Wed, 7 Aug 2019 10:06:37 +0000 (12:06 +0200)
Memory map array should be large enough to fit additional descriptors.

CORE-16216 CORE-16267

boot/freeldr/freeldr/arch/i386/pcmem.c
boot/freeldr/freeldr/arch/i386/xboxmem.c
boot/freeldr/freeldr/include/arch/pc/pcbios.h

index 2add4d9..4dd709b 100644 (file)
@@ -35,8 +35,6 @@ DBG_DEFAULT_CHANNEL(MEMORY);
 #define ULONGLONG_ALIGN_UP_BY(size, align) \
     (ULONGLONG_ALIGN_DOWN_BY(((ULONGLONG)(size) + align - 1), align))
 
-#define MAX_BIOS_DESCRIPTORS 80ul
-
 BIOS_MEMORY_MAP PcBiosMemoryMap[MAX_BIOS_DESCRIPTORS];
 ULONG PcBiosMapCount;
 
index ee5da0f..2d6890e 100644 (file)
@@ -89,12 +89,13 @@ XboxMemInit(VOID)
     AvailableMemoryMb = InstalledMemoryMb;
 }
 
-FREELDR_MEMORY_DESCRIPTOR XboxMemoryMap[2];
+FREELDR_MEMORY_DESCRIPTOR XboxMemoryMap[MAX_BIOS_DESCRIPTORS + 1];
 
 PFREELDR_MEMORY_DESCRIPTOR
 XboxMemGetMemoryMap(ULONG *MemoryMapSize)
 {
     TRACE("XboxMemGetMemoryMap()\n");
+    /* FIXME: Obtain memory map via multiboot spec */
 
     /* Synthesize memory map */
 
index 826a168..5ad273f 100644 (file)
@@ -3,6 +3,8 @@
 
 #ifndef __ASM__
 
+#define MAX_BIOS_DESCRIPTORS 80
+
 typedef enum
 {
     // ACPI 1.0.