Skip to content

Commit

Permalink
[Fixes] List itemId to vec.at() owerflow fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
jovibor committed Dec 19, 2019
1 parent 452a714 commit d26a068
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 13 deletions.
23 changes: 13 additions & 10 deletions Pepper/ViewRightBL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,16 @@ BOOL CViewRightBL::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT * pResult)

int CViewRightBL::CreateHexDosHeaderEntry(DWORD dwEntry)
{
if (dwEntry >= g_mapDOSHeader.size())
return -1;

if (m_hwndActive != m_stHexEdit->GetWindowHandle())
{
if (m_hwndActive)
::ShowWindow(m_hwndActive, SW_HIDE);
m_hwndActive = m_stHexEdit->GetWindowHandle();
}

CRect rc;
GetClientRect(&rc);
::SetWindowPos(m_hwndActive, m_hWnd, 0, 0, rc.Width(), rc.Height(), SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOZORDER);
Expand All @@ -228,7 +232,7 @@ int CViewRightBL::CreateHexDosHeaderEntry(DWORD dwEntry)
int CViewRightBL::CreateHexRichHeaderEntry(DWORD dwEntry)
{
PLIBPE_RICHHEADER_VEC pRichHeader;
if (m_pLibpe->GetRichHeader(pRichHeader) != S_OK)
if (m_pLibpe->GetRichHeader(pRichHeader) != S_OK || dwEntry >= pRichHeader->size())
return -1;

if (m_hwndActive != m_stHexEdit->GetWindowHandle())
Expand Down Expand Up @@ -269,7 +273,7 @@ int CViewRightBL::CreateHexNtHeaderEntry()
int CViewRightBL::CreateHexFileHeaderEntry(DWORD dwEntry)
{
PLIBPE_NTHEADER pNTHdr;
if (m_pLibpe->GetNTHeader(pNTHdr) != S_OK)
if (m_pLibpe->GetNTHeader(pNTHdr) != S_OK || dwEntry >= g_mapFileHeader.size())
return -1;

if (m_hwndActive != m_stHexEdit->GetWindowHandle())
Expand Down Expand Up @@ -355,11 +359,10 @@ int CViewRightBL::CreateHexDataDirsEntry(DWORD dwEntry)
return 0;
}


int CViewRightBL::CreateHexSecHeadersEntry(DWORD dwEntry)
{
PLIBPE_SECHEADERS_VEC pSecHeaders;
if (m_pLibpe->GetSectionsHeaders(pSecHeaders) != S_OK)
if (m_pLibpe->GetSectionsHeaders(pSecHeaders) != S_OK || dwEntry >= pSecHeaders->size())
return -1;

if (m_hwndActive != m_stHexEdit->GetWindowHandle())
Expand All @@ -381,7 +384,7 @@ int CViewRightBL::CreateHexSecHeadersEntry(DWORD dwEntry)
int CViewRightBL::CreateHexLCDEntry(DWORD dwEntry)
{
PLIBPE_LOADCONFIG pLCD;
if (m_pLibpe->GetLoadConfig(pLCD) != S_OK)
if (m_pLibpe->GetLoadConfig(pLCD) != S_OK || dwEntry >= g_mapLCD32.size())
return -1;

if (m_hwndActive != m_stHexEdit->GetWindowHandle())
Expand Down Expand Up @@ -476,7 +479,7 @@ int CViewRightBL::CreateListImportEntry(DWORD dwEntry)
m_listImportEntry->DeleteAllItems();

PLIBPE_IMPORT_VEC m_pImport;
if (m_pLibpe->GetImport(m_pImport) != S_OK || dwEntry > m_pImport->size())
if (m_pLibpe->GetImport(m_pImport) != S_OK || dwEntry >= m_pImport->size())
return -1;

if (m_hwndActive)
Expand Down Expand Up @@ -546,7 +549,7 @@ int CViewRightBL::CreateListImportEntry(DWORD dwEntry)
int CViewRightBL::CreateHexSecurityEntry(unsigned nSertId)
{
PLIBPE_SECURITY_VEC pSec;
if (m_pLibpe->GetSecurity(pSec) != S_OK || nSertId > pSec->size())
if (m_pLibpe->GetSecurity(pSec) != S_OK || nSertId >= pSec->size())
return -1;

const auto& secEntry = pSec->at(nSertId).stWinSert;
Expand Down Expand Up @@ -587,7 +590,7 @@ int CViewRightBL::CreateListDelayImportEntry(DWORD dwEntry)
m_listDelayImportEntry->DeleteAllItems();

PLIBPE_DELAYIMPORT_VEC pDelayImport;
if (m_pLibpe->GetDelayImport(pDelayImport) != S_OK || dwEntry > pDelayImport->size())
if (m_pLibpe->GetDelayImport(pDelayImport) != S_OK || dwEntry >= pDelayImport->size())
return -1;

int listindex = 0;
Expand Down Expand Up @@ -678,7 +681,7 @@ int CViewRightBL::CreateListRelocsEntry(DWORD dwEntry)
m_listRelocsEntry->DeleteAllItems();

PLIBPE_RELOCATION_VEC pReloc;
if (m_pLibpe->GetRelocations(pReloc) != S_OK || pReloc->empty() || pReloc->size() < dwEntry)
if (m_pLibpe->GetRelocations(pReloc) != S_OK || dwEntry >= pReloc->size())
return -1;

const std::map<WORD, std::wstring> mapRelocTypes {
Expand Down Expand Up @@ -729,7 +732,7 @@ int CViewRightBL::CreateListRelocsEntry(DWORD dwEntry)
int CViewRightBL::CreateHexDebugEntry(DWORD dwEntry)
{
PLIBPE_DEBUG_VEC pDebug;
if (m_pLibpe->GetDebug(pDebug) != S_OK)
if (m_pLibpe->GetDebug(pDebug) != S_OK || dwEntry >= pDebug->size())
return -1;

const auto& rDebugDir = pDebug->at(dwEntry).stDebugDir;
Expand Down
4 changes: 2 additions & 2 deletions Pepper/ViewRightTR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ void CViewRightTR::OnInitialUpdate()
//Hex control for Resources raw.
m_hcs.hwndParent = m_hWnd;
m_hcs.uID = IDC_HEX_RIGHT_TR;
m_stHexEdit->Create(m_hcs);
::ShowWindow(m_stHexEdit->GetWindowHandle(), SW_HIDE);
if (m_stHexEdit->Create(m_hcs))
::ShowWindow(m_stHexEdit->GetWindowHandle(), SW_HIDE);
}

void CViewRightTR::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* pHint)
Expand Down
Binary file modified Pepper/lib/HexCtrl64.lib
Binary file not shown.
Binary file modified Pepper/lib/HexCtrl64d.lib
Binary file not shown.
2 changes: 1 addition & 1 deletion Pepper/verinfo/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#define COPYRIGHT_NAME "(C) Jovibor 2019"
#define MAJOR_VERSION 1
#define MINOR_VERSION 2
#define MAINTENANCE_VERSION 0
#define MAINTENANCE_VERSION 1
#define REVISION_VERSION 0

0 comments on commit d26a068

Please sign in to comment.