mirror of
https://github.com/reactos/reactos.git
synced 2024-06-30 18:01:07 +00:00
[FREELDR] Additional safety checks for PcMemGetBiosMemoryMap. CORE-13332
Cast MAX_BIOS_DESCRIPTORS to explicit ULONG from implicit int. Comment/Add checks for PcMemoryMap/PcBiosMemoryMap arrays being full and bare handling of error cases.
This commit is contained in:
parent
fe3eb29287
commit
ba9a1c3abb
|
@ -33,7 +33,7 @@ DBG_DEFAULT_CHANNEL(MEMORY);
|
||||||
#define ULONGLONG_ALIGN_UP_BY(size, align) \
|
#define ULONGLONG_ALIGN_UP_BY(size, align) \
|
||||||
(ULONGLONG_ALIGN_DOWN_BY(((ULONGLONG)(size) + align - 1), align))
|
(ULONGLONG_ALIGN_DOWN_BY(((ULONGLONG)(size) + align - 1), align))
|
||||||
|
|
||||||
#define MAX_BIOS_DESCRIPTORS 80
|
#define MAX_BIOS_DESCRIPTORS 80ul
|
||||||
|
|
||||||
BIOS_MEMORY_MAP PcBiosMemoryMap[MAX_BIOS_DESCRIPTORS];
|
BIOS_MEMORY_MAP PcBiosMemoryMap[MAX_BIOS_DESCRIPTORS];
|
||||||
ULONG PcBiosMapCount;
|
ULONG PcBiosMapCount;
|
||||||
|
@ -368,6 +368,12 @@ PcMemGetBiosMemoryMap(PFREELDR_MEMORY_DESCRIPTOR MemoryMap, ULONG MaxMemoryMapSi
|
||||||
{
|
{
|
||||||
ERR("PcMemoryMap is already full! (PcBiosMapCount = %lu, PcMapCount = %lu (>= %lu))\n",
|
ERR("PcMemoryMap is already full! (PcBiosMapCount = %lu, PcMapCount = %lu (>= %lu))\n",
|
||||||
PcBiosMapCount, PcMapCount, MaxMemoryMapSize);
|
PcBiosMapCount, PcMapCount, MaxMemoryMapSize);
|
||||||
|
// NotWantedForPublicBuilds: ASSERTMSG("PcMemoryMap is already full!", FALSE);
|
||||||
|
/* We keep previous entries, and half-retrieve current/next entries.
|
||||||
|
* We assume all these entries are good to use as is. If they are not, we are in trouble...
|
||||||
|
*
|
||||||
|
* FIXME: Safer = revert (half-)retrieved entries, Safest = increase MaxMemoryMapSize.
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -390,6 +396,18 @@ nextRange:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Check whether there would be more entries to process. */
|
||||||
|
if (PcBiosMapCount >= MAX_BIOS_DESCRIPTORS && Regs.x.ebx != 0x00000000)
|
||||||
|
{
|
||||||
|
ERR("PcBiosMapCount is already full! (PcBiosMapCount = %lu (>= %lu), PcMapCount = %lu)\n",
|
||||||
|
PcBiosMapCount, MAX_BIOS_DESCRIPTORS, PcMapCount);
|
||||||
|
// NotWantedForPublicBuilds: ASSERTMSG("PcBiosMapCount is already full!", FALSE);
|
||||||
|
/* We keep retrieved entries, but ignore next entries.
|
||||||
|
* We assume these entries are good to use as is. If they are not, we are in trouble...
|
||||||
|
*
|
||||||
|
* FIXME: Safer = revert retrieved entries, Safest = increase MAX_BIOS_DESCRIPTORS.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
TRACE("PcMemGetBiosMemoryMap end: PcBiosMapCount = %lu\n", PcBiosMapCount);
|
TRACE("PcMemGetBiosMemoryMap end: PcBiosMapCount = %lu\n", PcBiosMapCount);
|
||||||
return PcBiosMapCount;
|
return PcBiosMapCount;
|
||||||
|
|
Loading…
Reference in a new issue