You've already forked linux-packaging-mono
Imported Upstream version 4.6.1.3
Former-commit-id: a3e5816ec0030ec68ca623935b6704cc0369f223
This commit is contained in:
parent
a306c5803a
commit
b7d1d80bf3
@@ -1927,20 +1927,6 @@ mono_domain_assembly_search (MonoAssemblyName *aname,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
prevent_running_reference_assembly (MonoAssembly *ass, MonoError *error)
|
||||
{
|
||||
mono_error_init (error);
|
||||
gboolean refasm = mono_assembly_get_reference_assembly_attribute (ass, error);
|
||||
if (!is_ok (error))
|
||||
return TRUE;
|
||||
if (refasm) {
|
||||
mono_error_set_bad_image (error, ass->image, "Could not load file or assembly or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context.\n");
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
MonoReflectionAssembly *
|
||||
ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname, MonoBoolean refOnly)
|
||||
{
|
||||
@@ -1949,40 +1935,37 @@ ves_icall_System_Reflection_Assembly_LoadFrom (MonoString *fname, MonoBoolean re
|
||||
MonoDomain *domain = mono_domain_get ();
|
||||
char *name, *filename;
|
||||
MonoImageOpenStatus status = MONO_IMAGE_OK;
|
||||
MonoAssembly *ass = NULL;
|
||||
|
||||
name = NULL;
|
||||
result = NULL;
|
||||
|
||||
mono_error_init (&error);
|
||||
MonoAssembly *ass;
|
||||
|
||||
if (fname == NULL) {
|
||||
mono_error_set_argument_null (&error, "assemblyFile", "");
|
||||
goto leave;
|
||||
MonoException *exc = mono_get_exception_argument_null ("assemblyFile");
|
||||
mono_set_pending_exception (exc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
name = filename = mono_string_to_utf8_checked (fname, &error);
|
||||
if (!is_ok (&error))
|
||||
goto leave;
|
||||
if (mono_error_set_pending_exception (&error))
|
||||
return NULL;
|
||||
|
||||
ass = mono_assembly_open_full (filename, &status, refOnly);
|
||||
|
||||
if (!ass) {
|
||||
MonoException *exc;
|
||||
|
||||
if (status == MONO_IMAGE_IMAGE_INVALID)
|
||||
mono_error_set_bad_image_name (&error, name, "");
|
||||
exc = mono_get_exception_bad_image_format2 (NULL, fname);
|
||||
else
|
||||
mono_error_set_exception_instance (&error, mono_get_exception_file_not_found2 (NULL, fname));
|
||||
goto leave;
|
||||
exc = mono_get_exception_file_not_found2 (NULL, fname);
|
||||
g_free (name);
|
||||
mono_set_pending_exception (exc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!refOnly && prevent_running_reference_assembly (ass, &error))
|
||||
goto leave;
|
||||
g_free (name);
|
||||
|
||||
result = mono_assembly_get_object_checked (domain, ass, &error);
|
||||
|
||||
leave:
|
||||
mono_error_set_pending_exception (&error);
|
||||
g_free (name);
|
||||
if (!result)
|
||||
mono_error_set_pending_exception (&error);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2017,11 +2000,6 @@ ves_icall_System_AppDomain_LoadAssemblyRaw (MonoAppDomain *ad,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!refonly && prevent_running_reference_assembly (ass, &error)) {
|
||||
mono_error_set_pending_exception (&error);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
refass = mono_assembly_get_object_checked (domain, ass, &error);
|
||||
if (!refass)
|
||||
mono_error_set_pending_exception (&error);
|
||||
@@ -2039,7 +2017,7 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad, MonoString *assRef,
|
||||
MonoAssembly *ass;
|
||||
MonoAssemblyName aname;
|
||||
MonoReflectionAssembly *refass = NULL;
|
||||
gchar *name = NULL;
|
||||
gchar *name;
|
||||
gboolean parsed;
|
||||
|
||||
g_assert (assRef);
|
||||
@@ -2048,13 +2026,16 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad, MonoString *assRef,
|
||||
if (mono_error_set_pending_exception (&error))
|
||||
return NULL;
|
||||
parsed = mono_assembly_name_parse (name, &aname);
|
||||
g_free (name);
|
||||
|
||||
if (!parsed) {
|
||||
/* This is a parse error... */
|
||||
if (!refOnly) {
|
||||
refass = mono_try_assembly_resolve (domain, assRef, NULL, refOnly, &error);
|
||||
if (!is_ok (&error))
|
||||
goto leave;
|
||||
if (!mono_error_ok (&error)) {
|
||||
mono_error_set_pending_exception (&error);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return refass;
|
||||
}
|
||||
@@ -2066,31 +2047,25 @@ ves_icall_System_AppDomain_LoadAssembly (MonoAppDomain *ad, MonoString *assRef,
|
||||
/* MS.NET doesn't seem to call the assembly resolve handler for refonly assemblies */
|
||||
if (!refOnly) {
|
||||
refass = mono_try_assembly_resolve (domain, assRef, NULL, refOnly, &error);
|
||||
if (!is_ok (&error))
|
||||
goto leave;
|
||||
if (!mono_error_ok (&error)) {
|
||||
mono_error_set_pending_exception (&error);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
refass = NULL;
|
||||
if (!refass)
|
||||
goto leave;
|
||||
ass = refass->assembly;
|
||||
if (!refass) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (!refOnly && prevent_running_reference_assembly (ass, &error))
|
||||
goto leave;
|
||||
|
||||
g_assert (ass);
|
||||
if (refass == NULL) {
|
||||
if (refass == NULL)
|
||||
refass = mono_assembly_get_object_checked (domain, ass, &error);
|
||||
if (!is_ok (&error))
|
||||
goto leave;
|
||||
}
|
||||
|
||||
MONO_OBJECT_SETREF (refass, evidence, evidence);
|
||||
|
||||
leave:
|
||||
g_free (name);
|
||||
mono_error_set_pending_exception (&error);
|
||||
if (refass == NULL)
|
||||
mono_error_set_pending_exception (&error);
|
||||
else
|
||||
MONO_OBJECT_SETREF (refass, evidence, evidence);
|
||||
return refass;
|
||||
}
|
||||
|
||||
|
||||
3653
mono/metadata/assembly.c
Normal file
3653
mono/metadata/assembly.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
7bd02ff37eea77a111cb30ce2d3b64953d487736
|
||||
@@ -1 +1 @@
|
||||
56e12ad673e2765956a4fc89dade62a15656a02f
|
||||
17da478b5e9c1f089d76de0bc275da6ab5e21077
|
||||
@@ -697,8 +697,4 @@ mono_runtime_init_checked (MonoDomain *domain, MonoThreadStartCB start_cb, MonoT
|
||||
void
|
||||
mono_context_init_checked (MonoDomain *domain, MonoError *error);
|
||||
|
||||
gboolean
|
||||
mono_assembly_get_reference_assembly_attribute (MonoAssembly *assembly, MonoError *error);
|
||||
|
||||
|
||||
#endif /* __MONO_METADATA_DOMAIN_INTERNALS_H__ */
|
||||
|
||||
@@ -807,16 +807,6 @@ mono_init_internal (const char *filename, const char *exe_filename, const char *
|
||||
|
||||
mono_profiler_appdomain_name (domain, domain->friendly_name);
|
||||
|
||||
/* Have to do this quite late so that we at least have System.Object */
|
||||
MonoError custom_attr_error;
|
||||
if (mono_assembly_get_reference_assembly_attribute (ass, &custom_attr_error)) {
|
||||
char *corlib_file = g_build_filename (mono_assembly_getrootdir (), "mono", current_runtime->framework_version, "mscorlib.dll", NULL);
|
||||
g_print ("Could not load file or assembly %s. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context.", corlib_file);
|
||||
g_free (corlib_file);
|
||||
exit (1);
|
||||
}
|
||||
mono_error_assert_ok (&custom_attr_error);
|
||||
|
||||
return domain;
|
||||
}
|
||||
|
||||
|
||||
@@ -824,7 +824,7 @@ EXTRA_DIST = TestDriver.cs \
|
||||
Makefile.am.in
|
||||
|
||||
version.h: Makefile
|
||||
echo "#define FULL_VERSION \"Stable 4.6.0.245/746756c\"" > version.h
|
||||
echo "#define FULL_VERSION \"Stable 4.6.1.3/abb06f1\"" > version.h
|
||||
|
||||
# Utility target for patching libtool to speed up linking
|
||||
patch-libtool:
|
||||
|
||||
@@ -824,7 +824,7 @@ EXTRA_DIST = TestDriver.cs \
|
||||
Makefile.am.in
|
||||
|
||||
version.h: Makefile
|
||||
echo "#define FULL_VERSION \"Stable 4.6.0.245/746756c\"" > version.h
|
||||
echo "#define FULL_VERSION \"Stable 4.6.1.3/abb06f1\"" > version.h
|
||||
|
||||
# Utility target for patching libtool to speed up linking
|
||||
patch-libtool:
|
||||
|
||||
@@ -1 +1 @@
|
||||
d4bf30694cd360d7152e64c43a9e4838e71f2c0c
|
||||
906197df9f69b49f888b78629651ab70ec983eaf
|
||||
@@ -1 +1 @@
|
||||
688594d96602b50770485925c92a521726edeea7
|
||||
995aea83d98094d62e65b814a85ba53c4744c5c1
|
||||
@@ -1 +1 @@
|
||||
1bf1ba6fa13f613a176781c0d4a9c16183273460
|
||||
33a4ca8d181b6ff7032ee475b3c355317dda43da
|
||||
@@ -1 +1 @@
|
||||
#define FULL_VERSION "Stable 4.6.0.245/746756c"
|
||||
#define FULL_VERSION "Stable 4.6.1.3/abb06f1"
|
||||
|
||||
@@ -436,8 +436,7 @@ BASE_TEST_CS_SRC= \
|
||||
pinvoke_ppci.cs \
|
||||
pinvoke_ppcf.cs \
|
||||
pinvoke_ppcd.cs \
|
||||
bug-29585.cs \
|
||||
reference-loader.cs
|
||||
bug-29585.cs
|
||||
|
||||
TEST_CS_SRC_DIST= \
|
||||
$(BASE_TEST_CS_SRC) \
|
||||
@@ -701,13 +700,11 @@ TEST_IL_SRC= \
|
||||
# but that need to be compiled
|
||||
PREREQ_IL_SRC=event-il.il module-cctor.il
|
||||
PREREQ_CS_SRC=
|
||||
PREREQ_IL_DLL_SRC=
|
||||
PREREQ_CS_DLL_SRC=TestingReferenceAssembly.cs TestingReferenceReferenceAssembly.cs
|
||||
PREREQ_IL_DLL_SRC=event-il.il module-cctor.il
|
||||
PREREQ_CS_DLL_SRC=
|
||||
|
||||
PREREQSI_IL=$(PREREQ_IL_SRC:.il=.exe) \
|
||||
$(PREREQ_IL_DLL_SRC:.il=.dll)
|
||||
PREREQSI_CS=$(PREREQ_CS_SRC:.cs=.exe) \
|
||||
$(PREREQ_CS_DLL_SRC:.cs=.dll)
|
||||
PREREQSI_IL=$(PREREQ_IL_SRC:.il=.exe)
|
||||
PREREQSI_CS=$(PREREQ_CS_SRC:.cs=.exe)
|
||||
TESTSI_CS=$(TEST_CS_SRC:.cs=.exe)
|
||||
TESTSI_IL=$(TEST_IL_SRC:.il=.exe)
|
||||
TESTBS=$(BENCHSRC:.cs=.exe)
|
||||
@@ -722,13 +719,6 @@ EXTRA_DIST=test-driver test-runner.cs $(TEST_CS_SRC_DIST) $(TEST_IL_SRC) \
|
||||
%.exe: %.cs TestDriver.dll
|
||||
$(MCS) -r:System.dll -r:System.Xml.dll -r:System.Core.dll -r:TestDriver.dll -r:Mono.Posix.dll -out:$@ $<
|
||||
|
||||
%.dll: %.cs
|
||||
$(MCS) -r:System.dll -target:library -out:$@ $<
|
||||
|
||||
TestingReferenceReferenceAssembly.dll: TestingReferenceReferenceAssembly.cs TestingReferenceAssembly.dll
|
||||
$(MCS) -r:TestingReferenceAssembly.dll -target:library -out:$@ $<
|
||||
|
||||
|
||||
# mkbundle works on ppc, but the pkg-config POC doesn't when run with make test
|
||||
if POWERPC
|
||||
test_platform:
|
||||
|
||||
@@ -842,8 +842,7 @@ BASE_TEST_CS_SRC = \
|
||||
pinvoke_ppci.cs \
|
||||
pinvoke_ppcf.cs \
|
||||
pinvoke_ppcd.cs \
|
||||
bug-29585.cs \
|
||||
reference-loader.cs
|
||||
bug-29585.cs
|
||||
|
||||
TEST_CS_SRC_DIST = \
|
||||
$(BASE_TEST_CS_SRC) \
|
||||
@@ -1057,14 +1056,10 @@ TEST_IL_SRC = \
|
||||
# but that need to be compiled
|
||||
PREREQ_IL_SRC = event-il.il module-cctor.il
|
||||
PREREQ_CS_SRC =
|
||||
PREREQ_IL_DLL_SRC =
|
||||
PREREQ_CS_DLL_SRC = TestingReferenceAssembly.cs TestingReferenceReferenceAssembly.cs
|
||||
PREREQSI_IL = $(PREREQ_IL_SRC:.il=.exe) \
|
||||
$(PREREQ_IL_DLL_SRC:.il=.dll)
|
||||
|
||||
PREREQSI_CS = $(PREREQ_CS_SRC:.cs=.exe) \
|
||||
$(PREREQ_CS_DLL_SRC:.cs=.dll)
|
||||
|
||||
PREREQ_IL_DLL_SRC = event-il.il module-cctor.il
|
||||
PREREQ_CS_DLL_SRC =
|
||||
PREREQSI_IL = $(PREREQ_IL_SRC:.il=.exe)
|
||||
PREREQSI_CS = $(PREREQ_CS_SRC:.cs=.exe)
|
||||
TESTSI_CS = $(TEST_CS_SRC:.cs=.exe)
|
||||
TESTSI_IL = $(TEST_IL_SRC:.il=.exe)
|
||||
TESTBS = $(BENCHSRC:.cs=.exe)
|
||||
@@ -1601,12 +1596,6 @@ aotcheck: testaot gshared-aot
|
||||
%.exe: %.cs TestDriver.dll
|
||||
$(MCS) -r:System.dll -r:System.Xml.dll -r:System.Core.dll -r:TestDriver.dll -r:Mono.Posix.dll -out:$@ $<
|
||||
|
||||
%.dll: %.cs
|
||||
$(MCS) -r:System.dll -target:library -out:$@ $<
|
||||
|
||||
TestingReferenceReferenceAssembly.dll: TestingReferenceReferenceAssembly.cs TestingReferenceAssembly.dll
|
||||
$(MCS) -r:TestingReferenceAssembly.dll -target:library -out:$@ $<
|
||||
|
||||
# mkbundle works on ppc, but the pkg-config POC doesn't when run with make test
|
||||
@POWERPC_TRUE@test_platform:
|
||||
# Can't use mkbundle on win32 since there is no static build there
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
//
|
||||
// reference-loader.cs:
|
||||
//
|
||||
// Test for reference assembly loading
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
public class Tests {
|
||||
public static int Main (string[] args)
|
||||
{
|
||||
return TestDriver.RunTests (typeof (Tests), args);
|
||||
}
|
||||
|
||||
public static int test_0_loadFrom_reference ()
|
||||
{
|
||||
// Check that loading a reference assembly by filename for execution is an error
|
||||
try {
|
||||
var a = Assembly.LoadFrom ("./TestingReferenceAssembly.dll");
|
||||
} catch (BadImageFormatException exn) {
|
||||
// Console.Error.WriteLine ("exn was {0}", exn);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int test_0_load_reference ()
|
||||
{
|
||||
// Check that loading a reference assembly for execution is an error
|
||||
try {
|
||||
var an = new AssemblyName ("TestingReferenceAssembly");
|
||||
var a = Assembly.Load (an);
|
||||
} catch (BadImageFormatException exn) {
|
||||
//Console.Error.WriteLine ("exn was {0}", exn);
|
||||
return 0;
|
||||
} catch (FileNotFoundException exn) {
|
||||
Console.Error.WriteLine ("incorrect exn was {0}", exn);
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int test_0_reflection_load_reference ()
|
||||
{
|
||||
// Check that reflection-only loading a reference assembly is okay
|
||||
var an = new AssemblyName ("TestingReferenceAssembly");
|
||||
var a = Assembly.ReflectionOnlyLoad (an.FullName);
|
||||
var t = a.GetType ("X");
|
||||
var f = t.GetField ("Y");
|
||||
if (f.FieldType.Equals (typeof (Int32)))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int test_0_load_reference_asm_via_reference ()
|
||||
{
|
||||
// Check that loading an assembly that references a reference assembly doesn't succeed.
|
||||
var an = new AssemblyName ("TestingReferenceReferenceAssembly");
|
||||
try {
|
||||
var a = Assembly.Load (an);
|
||||
var t = a.GetType ("Z");
|
||||
} catch (FileNotFoundException){
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int test_0_reflection_load_reference_asm_via_reference ()
|
||||
{
|
||||
// Check that reflection-only loading an assembly that
|
||||
// references a reference assembly is okay.
|
||||
var an = new AssemblyName ("TestingReferenceReferenceAssembly");
|
||||
var a = Assembly.ReflectionOnlyLoad (an.FullName);
|
||||
var t = a.GetType ("Z");
|
||||
var f = t.GetField ("Y");
|
||||
if (f.FieldType.Equals (typeof (Int32)))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
public static int test_0_load_reference_bytes ()
|
||||
{
|
||||
// Check that loading a reference assembly from a byte array for execution is an error
|
||||
byte[] bs = File.ReadAllBytes ("./TestingReferenceAssembly.dll");
|
||||
try {
|
||||
var a = Assembly.Load (bs);
|
||||
} catch (BadImageFormatException) {
|
||||
return 0;
|
||||
} catch (FileNotFoundException exn) {
|
||||
Console.Error.WriteLine ("incorrect exn was {0}", exn);
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public static int test_0_reflection_load_reference_bytes ()
|
||||
{
|
||||
// Check that loading a reference assembly from a byte
|
||||
// array for reflection only is okay.
|
||||
byte[] bs = File.ReadAllBytes ("./TestingReferenceAssembly.dll");
|
||||
var a = Assembly.ReflectionOnlyLoad (bs);
|
||||
var t = a.GetType ("X");
|
||||
var f = t.GetField ("Y");
|
||||
if (f.FieldType.Equals (typeof (Int32)))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user