提交 d3985be4 编写于 作者: P Paolo Molaro

Search for dllimported shared libs in the base directory, not cwd.

* loader.c: we don't search the current directory anymore for shared
libraries referenced in DllImport attributes, as it has a slight
security risk. We search in the same directory where the referencing
image was loaded from, instead. Fixes bug# 641915.
上级 6a5b2382
...@@ -1343,32 +1343,34 @@ mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char ...@@ -1343,32 +1343,34 @@ mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char
if (!module) { if (!module) {
void *iter = NULL; void *iter = NULL;
while ((full_name = mono_dl_build_path (NULL, file_name, &iter))) { char *mdirname = g_path_get_dirname (image->name);
while ((full_name = mono_dl_build_path (mdirname, file_name, &iter))) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT, mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
"DllImport loading location: '%s'.", full_name); "DllImport loading library: '%s'.", full_name);
module = cached_module_load (full_name, MONO_DL_LAZY, &error_msg); module = cached_module_load (full_name, MONO_DL_LAZY, &error_msg);
if (!module) { if (!module) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT, mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
"DllImport error loading library: '%s'.", "DllImport error loading library '%s'.",
error_msg); error_msg);
g_free (error_msg); g_free (error_msg);
} }
g_free (full_name); g_free (full_name);
if (module) if (module)
break; break;
} }
g_free (mdirname);
} }
if (!module) { if (!module) {
void *iter = NULL; void *iter = NULL;
while ((full_name = mono_dl_build_path (".", file_name, &iter))) { while ((full_name = mono_dl_build_path (NULL, file_name, &iter))) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT, mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
"DllImport loading library: '%s'.", full_name); "DllImport loading location: '%s'.", full_name);
module = cached_module_load (full_name, MONO_DL_LAZY, &error_msg); module = cached_module_load (full_name, MONO_DL_LAZY, &error_msg);
if (!module) { if (!module) {
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT, mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
"DllImport error loading library '%s'.", "DllImport error loading library: '%s'.",
error_msg); error_msg);
g_free (error_msg); g_free (error_msg);
} }
g_free (full_name); g_free (full_name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册