Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Handle invalid instantiation of generic methods.

	* verify.c: Add new function to internal verifier API to check
	method instantiations.

	* reflection.c (mono_reflection_bind_generic_method_parameters):
	Check the instantiation before returning it.

	Fixes #655847
  • Loading branch information...
commit 4905ef1130feb26c3150b28b97e4a96752e0d399 1 parent 472119d
@kumpera kumpera authored
View
3  mono/metadata/reflection.c
@@ -10176,6 +10176,9 @@ mono_reflection_bind_generic_method_parameters (MonoReflectionMethod *rmethod, M
mono_g_hash_table_insert (image->generic_def_objects, imethod, rmethod);
mono_loader_unlock ();
}
+
+ if (!mono_verifier_is_method_valid_generic_instantiation (inflated))
+ mono_raise_exception (mono_get_exception_argument ("typeArguments", "Invalid generic arguments"));
return mono_method_get_object (mono_object_domain (rmethod), inflated, NULL);
}
View
1  mono/metadata/verify-internals.h
@@ -22,6 +22,7 @@ gboolean mono_verifier_is_enabled_for_class (MonoClass *klass) MONO_INTERNAL;
gboolean mono_verifier_is_method_full_trust (MonoMethod *method) MONO_INTERNAL;
gboolean mono_verifier_is_class_full_trust (MonoClass *klass) MONO_INTERNAL;
gboolean mono_verifier_class_is_valid_generic_instantiation (MonoClass *class) MONO_INTERNAL;
+gboolean mono_verifier_is_method_valid_generic_instantiation (MonoMethod *method) MONO_INTERNAL;
gboolean mono_verifier_verify_class (MonoClass *klass) MONO_INTERNAL;
View
15 mono/metadata/verify.c
@@ -6533,6 +6533,14 @@ mono_verifier_class_is_valid_generic_instantiation (MonoClass *class)
return mono_class_is_valid_generic_instantiation (NULL, class);
}
+gboolean
+mono_verifier_is_method_valid_generic_instantiation (MonoMethod *method)
+{
+ if (!method->is_inflated)
+ return TRUE;
+ return mono_method_is_valid_generic_instantiation (NULL, method);
+}
+
#else
gboolean
@@ -6611,5 +6619,12 @@ mono_verifier_class_is_valid_generic_instantiation (MonoClass *class)
return TRUE;
}
+gboolean
+mono_verifier_is_method_valid_generic_instantiation (MonoMethod *method)
+{
+ return TRUE;
+}
+
+
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.