File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -271,9 +271,11 @@ std::tstring Injector::GetPath( const std::tstring& ModuleName )
271271 if (PathIsRelative (ModuleName.c_str ()))
272272 {
273273 std::vector<TCHAR> LoaderPath (MAX_PATH);
274- if (! GetModuleFileName (NULL , &LoaderPath[0 ], static_cast <DWORD>(LoaderPath.size ())) ||
275- GetLastError () == ERROR_INSUFFICIENT_BUFFER )
274+ const DWORD LoaderPathLen = GetModuleFileName (NULL , &LoaderPath[0 ], static_cast <DWORD>(LoaderPath.size ()));
275+ if (LoaderPathLen == 0 )
276276 throw std::runtime_error (" Could not get path to loader." );
277+ if (LoaderPathLen >= static_cast <DWORD>(LoaderPath.size ()))
278+ throw std::runtime_error (" Path to loader exceeds MAX_PATH and was truncated." );
277279
278280 std::tstring LoaderDir (&LoaderPath[0 ]);
279281 LoaderDir = LoaderDir.substr (0 , LoaderDir.rfind (_T (" \\ " )) + 1 );
You can’t perform that action at this time.
0 commit comments