Fix not-null terminated section names

dependabot/npm_and_yarn/Src/WebController/UI/websocket-extensions-0.1.4
Grzegorz Rychlik 2020-01-17 14:00:51 +01:00
parent fb849016ea
commit 41b16a3c32
1 changed files with 4 additions and 1 deletions

View File

@ -154,7 +154,10 @@ namespace MWR::Loader::UnexportedWinApi
auto sectionHeader = IMAGE_FIRST_SECTION(ntHeaders);
for (int i = 0; i < ntHeaders->FileHeader.NumberOfSections; i++, sectionHeader++)
{
if (_stricmp(section.c_str(), (char*)sectionHeader->Name) == 0)
char currentSection[9];
memcpy(currentSection, sectionHeader->Name, 8);
currentSection[8] = 0; // ensure null-termination
if (_stricmp(section.c_str(), currentSection) == 0)
{
auto sectionVa = Rva2Va<char*>(dllBase, sectionHeader->VirtualAddress);
return { sectionVa, sectionVa + sectionHeader->Misc.VirtualSize };