File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -136,7 +136,9 @@ struct Module : public ispcrt::base::Module {
136
136
#endif
137
137
void *lib = nullptr ;
138
138
#if defined _WIN32
139
- lib = LoadLibrary ((m_file + ext).c_str ());
139
+ // Removes CWD from the search path to reduce the risk of DLL injection.
140
+ SetDllDirectory (" " );
141
+ lib = LoadLibraryEx ((m_file + ext).c_str (), NULL , 0 );
140
142
#else
141
143
lib = dlopen ((" lib" + m_file + ext).c_str (), RTLD_LAZY | RTLD_LOCAL);
142
144
#endif
Original file line number Diff line number Diff line change @@ -129,7 +129,9 @@ static OBJECT_T &referenceFromHandle(HANDLE_T handle) {
129
129
// OS agnostic function to dynamically load a shared library.
130
130
void *dyn_load_lib (const char *name, const char *name_major_version, const char *name_full_version) {
131
131
#if defined(_WIN32) || defined(_WIN64)
132
- return LoadLibrary (name);
132
+ // Removes CWD from the search path to reduce the risk of DLL injection.
133
+ SetDllDirectory (" " );
134
+ return LoadLibraryEx (name, NULL , 0 );
133
135
#else
134
136
// Try to load a device library starting from the most specific name down to more general one.
135
137
void *handle = dlopen (name_full_version, RTLD_NOW | RTLD_LOCAL);
You can’t perform that action at this time.
0 commit comments