2010-04-13 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Tue, 13 Apr 2010 22:59:47 +0000 (22:59 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 13 Apr 2010 22:59:47 +0000 (22:59 -0000)
* reflection.c: Use the new verifier support for checking
custom attributes.

Fixes #595306.

svn path=/trunk/mono/; revision=155345

mono/metadata/ChangeLog
mono/metadata/reflection.c

index 93f9022fe604a3760567d56768dba69fbe8d3794..1eb3afb20709a8851cacab7705666649e9ced893 100644 (file)
@@ -1,3 +1,10 @@
+2010-04-13 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * reflection.c: Use the new verifier support for checking
+       custom attributes.
+
+       Fixes #595306.
+
 2010-04-13 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * metadata-verify.c: Implement structural verification
index e4efda07449cb9c2d63d7665c2a00183d242b9c4..0382eee244d6c8178c9b2c28fd0671f93f11c546 100644 (file)
@@ -38,6 +38,7 @@
 #include <mono/metadata/mempool-internals.h>
 #include <mono/metadata/security-core-clr.h>
 #include <mono/metadata/debug-helpers.h>
+#include <mono/metadata/verify-internals.h>
 #include <mono/utils/mono-string.h>
 #include <mono/utils/mono-error-internals.h>
 
@@ -8071,6 +8072,9 @@ create_custom_attr (MonoImage *image, MonoMethod *method, const guchar *data, gu
 
        mono_class_init (method->klass);
 
+       if (!mono_verifier_verify_cattr_content (image, method, data, len, NULL))
+               return NULL;
+
        if (len == 0) {
                attr = mono_object_new (mono_domain_get (), method->klass);
                mono_runtime_invoke (method, attr, NULL, NULL);
@@ -8171,6 +8175,9 @@ mono_reflection_create_custom_attr_data_args (MonoImage *image, MonoMethod *meth
        guint32 i, j, num_named;
        CattrNamedArg *arginfo = NULL;
 
+       if (!mono_verifier_verify_cattr_content (image, method, data, len, NULL))
+               return;
+
        mono_class_init (method->klass);
 
        *typed_args = NULL;
@@ -8443,6 +8450,14 @@ mono_custom_attrs_from_index (MonoImage *image, guint32 idx)
                        g_free (ainfo);
                        return NULL;
                }
+
+               if (!mono_verifier_verify_cattr_blob (image, cols [MONO_CUSTOM_ATTR_VALUE], NULL)) {
+                       /*FIXME raising an exception here doesn't make any sense*/
+                       g_warning ("Invalid custom attribute blob on image %s for index %x", image->name, idx);
+                       g_free (ainfo);
+                       g_free (list);
+                       return NULL;
+               }
                data = mono_metadata_blob_heap (image, cols [MONO_CUSTOM_ATTR_VALUE]);
                ainfo->attrs [i].data_size = mono_metadata_decode_value (data, &data);
                ainfo->attrs [i].data = (guchar*)data;