Skip to content

Commit 78eb433

Browse files
author
bot-1450
authored
[SecurityCritical] Fix Overflow.
Fix security vulnerability: potential overflow. nSize in characters, not in bytes.
1 parent 968349f commit 78eb433

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Injector/Injector.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ BYTE* Injector::GetModuleBaseAddress(HANDLE Process, const std::wstring& Path) {
6464
{
6565
WCHAR ModuleName[MAX_PATH];
6666
WCHAR ExePath[MAX_PATH];
67-
if (!GetModuleBaseNameW(Process, Module, ModuleName, sizeof(ModuleName)))
67+
// The size of the ModuleName buffer, in characters.
68+
if (!GetModuleBaseNameW(Process, Module, ModuleName, sizeof(ModuleName) / sizeof(WCHAR)))
6869
throw std::runtime_error("Could not get ModuleName.");
69-
if (!GetModuleFileNameExW(Process, Module, ExePath, sizeof(ExePath)))
70+
// The size of the ExePath buffer, in characters.
71+
if (!GetModuleFileNameExW(Process, Module, ExePath, sizeof(ExePath) / sizeof(WCHAR)))
7072
throw std::runtime_error("Could not get ExePath.");
7173
Found = (icompare(ModuleName, Path) || icompare(ExePath, Path));
7274
if (Found)

0 commit comments

Comments
 (0)