[Mono-dev] [PATCH] mono_ldtoken returns wrong token / mono_class_get_full don't give access to type metadata

Rodrigo Kumpera kumpera at gmail.com
Wed Aug 8 18:43:28 EDT 2007


Hey guys,

The attached patch fixes a bug and fill a gap of something I need for the
verifier. First I'll explain the issue with mono_class_get_full and then the
bug.

The issue is that TYPE_SPEC tokens can be byref (int& for example) and have
attached attributes to it, since mono_class_get_full returns MonoClass*, it
doesn't allow access to that info.

If you use mono_class_get_full on the type_spec token (int&) you will
receive back the MonoClass* instance for System.Int32 and will have no way
do diferenciate if the token was 'int' or 'int32'. This issue strikes me on
some spots that the verifier should block invalid code.

The bug related to that happens in mono_ldtoken, that uses
mono_class_get_full to resolve the token. It happens that all tokens that
carry metadata are not loader correctly. This is not a big issue because you
cannot do something like "typeof (int&)" in C#.

The attached patch fixes this bug and export a new function
mono_type_get_full from class.h that works exactly like mono_class_get_full
but returns MonoType. The only thing with this patch is that it should not
work with dynamic images as I haven't done anything about.

Cheers,
Rodrigo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070808/e4f7aad5/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: typespec.diff
Type: text/x-patch
Size: 3120 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070808/e4f7aad5/attachment.bin 


More information about the Mono-devel-list mailing list