Author: zoltan
Date: 2007-12-23 15:45:30 -0500 (Sun, 23 Dec 2007)
New Revision: 91842

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/class.c
   trunk/mono/mono/metadata/loader.c
Log:
2007-12-23  Zoltan Varga  <[EMAIL PROTECTED]>

        * loader.c (field_from_memberref): Remove the dynamic case, it is 
handled in
        the caller.

        * class.c (mono_class_get_full): Check the token type in the dynamic 
case.

        * loader.c (mono_field_from_token): Ditto.      

        * loader.c (mono_get_method_from_token): Change the check so it checks 
memberref
        type as well.


Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2007-12-23 20:17:33 UTC (rev 91841)
+++ trunk/mono/mono/metadata/ChangeLog  2007-12-23 20:45:30 UTC (rev 91842)
@@ -1,5 +1,15 @@
 2007-12-23  Zoltan Varga  <[EMAIL PROTECTED]>
 
+       * loader.c (field_from_memberref): Remove the dynamic case, it is 
handled in
+       the caller.
+
+       * class.c (mono_class_get_full): Check the token type in the dynamic 
case.
+
+       * loader.c (mono_field_from_token): Ditto.      
+
+       * loader.c (mono_get_method_from_token): Change the check so it checks 
memberref
+       type as well.
+       
        * loader.c (mono_get_method_from_token): Check the token type in the 
dynamic case.
        Fixes #342565.
 

Modified: trunk/mono/mono/metadata/class.c
===================================================================
--- trunk/mono/mono/metadata/class.c    2007-12-23 20:17:33 UTC (rev 91841)
+++ trunk/mono/mono/metadata/class.c    2007-12-23 20:45:30 UTC (rev 91842)
@@ -4529,8 +4529,15 @@
 {
        MonoClass *class = NULL;
 
-       if (image->dynamic)
+       if (image->dynamic) {
+               int table = mono_metadata_token_table (type_token);
+
+               if (table != MONO_TABLE_TYPEDEF && table != MONO_TABLE_TYPEREF 
&& table != MONO_TABLE_TYPESPEC) {
+                       mono_loader_set_error_bad_image (g_strdup ("Bad type 
token."));
+                       return NULL;
+               }
                return mono_lookup_dynamic_token (image, type_token, context);
+       }
 
        switch (type_token & 0xff000000){
        case MONO_TOKEN_TYPE_DEF:

Modified: trunk/mono/mono/metadata/loader.c
===================================================================
--- trunk/mono/mono/metadata/loader.c   2007-12-23 20:17:33 UTC (rev 91841)
+++ trunk/mono/mono/metadata/loader.c   2007-12-23 20:45:30 UTC (rev 91842)
@@ -344,12 +344,6 @@
        const char *ptr;
        guint32 idx = mono_metadata_token_index (token);
 
-       if (image->dynamic) {
-               MonoClassField *result = mono_lookup_dynamic_token (image, 
token, context);
-               *retklass = result->parent;
-               return result;
-       }
-
        mono_metadata_decode_row (&tables [MONO_TABLE_MEMBERREF], idx-1, cols, 
MONO_MEMBERREF_SIZE);
        nindex = cols [MONO_MEMBERREF_CLASS] >> MONO_MEMBERREF_PARENT_BITS;
        class = cols [MONO_MEMBERREF_CLASS] & MONO_MEMBERREF_PARENT_MASK;
@@ -428,7 +422,16 @@
        MonoClassField *field;
 
        if (image->dynamic) {
-               MonoClassField *result = mono_lookup_dynamic_token (image, 
token, context);
+               MonoClassField *result;
+               MonoClass *handle_class;
+
+               *retklass = NULL;
+               result = mono_lookup_dynamic_token_class (image, token, TRUE, 
&handle_class, context);
+               // This checks the memberref type as well
+               if (result && handle_class != mono_defaults.fieldhandle_class) {
+                       mono_loader_set_error_bad_image (g_strdup ("Bad field 
token."));
+                       return NULL;
+               }
                *retklass = result->parent;
                return result;
        }
@@ -1313,11 +1316,15 @@
        guint32 cols [MONO_TYPEDEF_SIZE];
 
        if (image->dynamic) {
-               if (table != MONO_TABLE_METHOD && table != 
MONO_TABLE_METHODSPEC && table != MONO_TABLE_MEMBERREF) {
+               MonoClass *handle_class;
+
+               result = mono_lookup_dynamic_token_class (image, token, TRUE, 
&handle_class, context);
+               // This checks the memberref type as well
+               if (result && handle_class != mono_defaults.methodhandle_class) 
{
                        mono_loader_set_error_bad_image (g_strdup ("Bad method 
token."));
                        return NULL;
                }
-               return mono_lookup_dynamic_token (image, token, context);
+               return result;
        }
 
        if (table != MONO_TABLE_METHOD) {

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to