mirror of
https://github.com/reactos/reactos.git
synced 2024-08-12 14:16:30 +00:00
- Add a check for an incorrect virtual size. Currently ReactOS's floppy.sys has such an incorrect section.
svn path=/trunk/; revision=30691
This commit is contained in:
parent
d4e96ba358
commit
787a5cdaa4
|
@ -24,8 +24,9 @@ RosSymCreateFromMem(PVOID ImageStart, ULONG_PTR ImageSize, PROSSYM_INFO *RosSymI
|
||||||
PIMAGE_DOS_HEADER DosHeader;
|
PIMAGE_DOS_HEADER DosHeader;
|
||||||
PIMAGE_NT_HEADERS NtHeaders;
|
PIMAGE_NT_HEADERS NtHeaders;
|
||||||
PIMAGE_SECTION_HEADER SectionHeader;
|
PIMAGE_SECTION_HEADER SectionHeader;
|
||||||
unsigned SectionIndex;
|
ULONG SectionIndex;
|
||||||
char SectionName[IMAGE_SIZEOF_SHORT_NAME];
|
BOOLEAN RosSymSectionFound = FALSE;
|
||||||
|
CHAR SectionName[IMAGE_SIZEOF_SHORT_NAME];
|
||||||
|
|
||||||
/* Check if MZ header is valid */
|
/* Check if MZ header is valid */
|
||||||
DosHeader = (PIMAGE_DOS_HEADER) ImageStart;
|
DosHeader = (PIMAGE_DOS_HEADER) ImageStart;
|
||||||
|
@ -58,11 +59,13 @@ RosSymCreateFromMem(PVOID ImageStart, ULONG_PTR ImageSize, PROSSYM_INFO *RosSymI
|
||||||
{
|
{
|
||||||
if (0 == memcmp(SectionName, SectionHeader->Name, IMAGE_SIZEOF_SHORT_NAME))
|
if (0 == memcmp(SectionName, SectionHeader->Name, IMAGE_SIZEOF_SHORT_NAME))
|
||||||
{
|
{
|
||||||
|
RosSymSectionFound = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SectionHeader++;
|
SectionHeader++;
|
||||||
}
|
}
|
||||||
if (NtHeaders->FileHeader.NumberOfSections <= SectionIndex)
|
|
||||||
|
if (!RosSymSectionFound)
|
||||||
{
|
{
|
||||||
DPRINT("No %s section found\n", ROSSYM_SECTION_NAME);
|
DPRINT("No %s section found\n", ROSSYM_SECTION_NAME);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -76,6 +79,12 @@ RosSymCreateFromMem(PVOID ImageStart, ULONG_PTR ImageSize, PROSSYM_INFO *RosSymI
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (SectionHeader->VirtualAddress + SectionHeader->Misc.VirtualSize > ImageSize)
|
||||||
|
{
|
||||||
|
DPRINT("Bad %s section virtual size!\n", ROSSYM_SECTION_NAME);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Load it */
|
/* Load it */
|
||||||
return RosSymCreateFromRaw((char *) ImageStart + SectionHeader->VirtualAddress,
|
return RosSymCreateFromRaw((char *) ImageStart + SectionHeader->VirtualAddress,
|
||||||
SectionHeader->SizeOfRawData, RosSymInfo);
|
SectionHeader->SizeOfRawData, RosSymInfo);
|
||||||
|
|
Loading…
Reference in a new issue