Skip to content

Commit 3c036ed

Browse files
authored
Merge pull request #520 from WPMGPRoSToTeMa/safeloading
Make DLL loading more safe
2 parents 4246a44 + 0d20fdf commit 3c036ed

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

rehlds/dedicated/src/sys_linux.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,11 @@ long CSys::LoadLibrary(char *lib)
227227

228228
Q_snprintf(absolute_lib, sizeof(absolute_lib), "%s/%s", cwd, lib);
229229

230+
#ifdef LAUNCHER_FIXES
231+
void *hDll = dlopen(absolute_lib, RTLD_NOW | RTLD_DEEPBIND | RTLD_LOCAL);
232+
#else // LAUNCHER_FIXES
230233
void *hDll = dlopen(absolute_lib, RTLD_NOW);
234+
#endif // LAUNCHER_FIXES
231235
if (!hDll)
232236
{
233237
ErrorMessage(1, dlerror());

rehlds/engine/filesystem_internal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ void *FS_LoadLibrary(const char *dllName)
330330
#ifdef _WIN32
331331
result = LoadLibraryA(dllName);
332332
#else
333-
result = dlopen(dllName, 2);
333+
result = dlopen(dllName, RTLD_NOW);
334334
#endif
335335
}
336336

rehlds/engine/sys_dll.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,11 @@ void LoadThisDll(const char *szDllFilename)
10671067
goto IgnoreThisDLL;
10681068
}
10691069
#else // _WIN32
1070+
#ifdef REHLDS_FIXES
1071+
void *hDLL = dlopen(szDllFilename, RTLD_NOW | RTLD_DEEPBIND | RTLD_LOCAL);
1072+
#else // REHLDS_FIXES
10701073
void *hDLL = dlopen(szDllFilename, RTLD_NOW);
1074+
#endif // REHLDS_FIXES
10711075
if (!hDLL)
10721076
{
10731077
Con_Printf("LoadLibrary failed on %s: %s\n", szDllFilename, dlerror());

0 commit comments

Comments
 (0)