2010-04-09 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / metadata / metadata-verify.c
index 0f99fbca38a60cf4d9fbab63818e54e51cb7a077..0ffb428a92d5b64c8396455bea201d06e2f82540 100644 (file)
@@ -1267,6 +1267,12 @@ parse_generic_inst (VerifyContext *ctx, const char **_ptr, const char *end)
        if (!is_valid_coded_index (ctx, TYPEDEF_OR_REF_DESC, token))
                FAIL (ctx, g_strdup_printf ("GenericInst: invalid TypeDefOrRef token %x", token));
 
+       if (ctx->token) {
+               if (mono_metadata_token_index (ctx->token) == get_coded_index_token (TYPEDEF_OR_REF_DESC, token) &&
+                       mono_metadata_token_table (ctx->token) == get_coded_index_table (TYPEDEF_OR_REF_DESC, token))
+                       FAIL (ctx, g_strdup_printf ("Type: Recurside generic instance specification (%x). A type signature can't reference itself", ctx->token));
+       }
+
        if (!safe_read_cint (count, ptr, end))
                FAIL (ctx, g_strdup ("GenericInst: Not enough room for argument count"));
 
@@ -1689,6 +1695,11 @@ is_valid_standalonesig_blob (VerifyContext *ctx, guint32 offset)
        --ptr;
        if (signature == 0x07)
                return parse_locals_signature (ctx, &ptr, end);
+
+       /*F# and managed C++ produce standalonesig for fields even thou the spec doesn't mention it.*/
+       if (signature == 0x06)
+               return parse_field (ctx, &ptr, end);
+
        return parse_method_signature (ctx, &ptr, end, TRUE, TRUE);
 }
 
@@ -2100,8 +2111,10 @@ verify_typedef_table_full (VerifyContext *ctx)
                mono_metadata_decode_row (table, i, data, MONO_TYPEDEF_SIZE);
 
                if (i == 0) {
-                       if (data [MONO_TYPEDEF_EXTENDS] != 0)
+                       /*XXX it's ok if <module> extends object, or anything at all, actually. */
+                       /*if (data [MONO_TYPEDEF_EXTENDS] != 0)
                                ADD_ERROR (ctx, g_strdup_printf ("Invalid typedef row 0 for the special <module> type must have a null extend field"));
+                       */
                        continue;
                }
 
@@ -2207,8 +2220,8 @@ verify_field_table_full (VerifyContext *ctx)
        }
 }
 
-/*bits 6,8,9,10,11,13,14,15*/
-#define INVALID_METHOD_IMPLFLAG_BITS ((1 << 6) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 13) | (1 << 14) | (1 << 15))
+/*bits 8,9,10,11,13,14,15*/
+#define INVALID_METHOD_IMPLFLAG_BITS ((1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 13) | (1 << 14) | (1 << 15))
 static void
 verify_method_table (VerifyContext *ctx)
 {