2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-02-27 14:01:18 +03:00

Merge pull request #520 from WPMGPRoSToTeMa/safeloading

Make DLL loading more safe
This commit is contained in:
theAsmodai 2017-09-13 02:07:13 +02:00 committed by GitHub
commit 3c036eda31
3 changed files with 9 additions and 1 deletions

View File

@ -227,7 +227,11 @@ long CSys::LoadLibrary(char *lib)
Q_snprintf(absolute_lib, sizeof(absolute_lib), "%s/%s", cwd, lib);
#ifdef LAUNCHER_FIXES
void *hDll = dlopen(absolute_lib, RTLD_NOW | RTLD_DEEPBIND | RTLD_LOCAL);
#else // LAUNCHER_FIXES
void *hDll = dlopen(absolute_lib, RTLD_NOW);
#endif // LAUNCHER_FIXES
if (!hDll)
{
ErrorMessage(1, dlerror());

View File

@ -330,7 +330,7 @@ void *FS_LoadLibrary(const char *dllName)
#ifdef _WIN32
result = LoadLibraryA(dllName);
#else
result = dlopen(dllName, 2);
result = dlopen(dllName, RTLD_NOW);
#endif
}

View File

@ -1067,7 +1067,11 @@ void LoadThisDll(const char *szDllFilename)
goto IgnoreThisDLL;
}
#else // _WIN32
#ifdef REHLDS_FIXES
void *hDLL = dlopen(szDllFilename, RTLD_NOW | RTLD_DEEPBIND | RTLD_LOCAL);
#else // REHLDS_FIXES
void *hDLL = dlopen(szDllFilename, RTLD_NOW);
#endif // REHLDS_FIXES
if (!hDLL)
{
Con_Printf("LoadLibrary failed on %s: %s\n", szDllFilename, dlerror());