Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.
  • Loading branch information...
commit 8e890a3bf80a4620e417814dc14886b1bbd17625 1 parent b80ffc9
Paolo Molaro authored

Showing 1 changed file with 10 additions and 8 deletions. Show diff stats Hide diff stats

  1. 18  mono/metadata/loader.c
18  mono/metadata/loader.c
@@ -1340,32 +1340,34 @@ mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char
1340 1340
 
1341 1341
 		if (!module) {
1342 1342
 			void *iter = NULL;
1343  
-			while ((full_name = mono_dl_build_path (NULL, file_name, &iter))) {
  1343
+			char *mdirname = g_path_get_dirname (image->name);
  1344
+			while ((full_name = mono_dl_build_path (mdirname, file_name, &iter))) {
1344 1345
 				mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
1345  
-						"DllImport loading location: '%s'.", full_name);
  1346
+					"DllImport loading library: '%s'.", full_name);
1346 1347
 				module = cached_module_load (full_name, MONO_DL_LAZY, &error_msg);
1347 1348
 				if (!module) {
1348 1349
 					mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
1349  
-							"DllImport error loading library: '%s'.",
1350  
-							error_msg);
  1350
+						"DllImport error loading library '%s'.",
  1351
+						error_msg);
1351 1352
 					g_free (error_msg);
1352 1353
 				}
1353 1354
 				g_free (full_name);
1354 1355
 				if (module)
1355 1356
 					break;
1356 1357
 			}
  1358
+			g_free (mdirname);
1357 1359
 		}
1358 1360
 
1359 1361
 		if (!module) {
1360 1362
 			void *iter = NULL;
1361  
-			while ((full_name = mono_dl_build_path (".", file_name, &iter))) {
  1363
+			while ((full_name = mono_dl_build_path (NULL, file_name, &iter))) {
1362 1364
 				mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
1363  
-					"DllImport loading library: '%s'.", full_name);
  1365
+						"DllImport loading location: '%s'.", full_name);
1364 1366
 				module = cached_module_load (full_name, MONO_DL_LAZY, &error_msg);
1365 1367
 				if (!module) {
1366 1368
 					mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_DLLIMPORT,
1367  
-						"DllImport error loading library '%s'.",
1368  
-						error_msg);
  1369
+							"DllImport error loading library: '%s'.",
  1370
+							error_msg);
1369 1371
 					g_free (error_msg);
1370 1372
 				}
1371 1373
 				g_free (full_name);

0 notes on commit 8e890a3

Please sign in to comment.
Something went wrong with that request. Please try again.