Author: zoltan
Date: 2007-12-05 08:18:22 -0500 (Wed, 05 Dec 2007)
New Revision: 90762
Modified:
trunk/mono/mono/metadata/ChangeLog
trunk/mono/mono/metadata/icall.c
Log:
2007-12-05 Zoltan Varga <[EMAIL PROTECTED]>
* icall.c (ves_icall_MonoField_GetValueInternal): Check that the field
belongs
to the target object's type. Fixes #346160.
Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog 2007-12-05 13:18:13 UTC (rev 90761)
+++ trunk/mono/mono/metadata/ChangeLog 2007-12-05 13:18:22 UTC (rev 90762)
@@ -1,3 +1,8 @@
+2007-12-05 Zoltan Varga <[EMAIL PROTECTED]>
+
+ * icall.c (ves_icall_MonoField_GetValueInternal): Check that the field
belongs
+ to the target object's type. Fixes #346160.
+
2007-12-05 Dick Porter <[EMAIL PROTECTED]>
* threadpool.c (socket_io_add_poll): Asynchronous connect() on
Modified: trunk/mono/mono/metadata/icall.c
===================================================================
--- trunk/mono/mono/metadata/icall.c 2007-12-05 13:18:13 UTC (rev 90761)
+++ trunk/mono/mono/metadata/icall.c 2007-12-05 13:18:22 UTC (rev 90762)
@@ -1505,6 +1505,29 @@
mono_class_init (field->klass);
+ if (cf->type->attrs & FIELD_ATTRIBUTE_STATIC)
+ is_static = TRUE;
+
+ if (obj && !is_static) {
+ /* Check that the field belongs to the object */
+ gboolean found = FALSE;
+ MonoClass *k;
+
+ for (k = obj->vtable->klass; k; k = k->parent) {
+ if (k == cf->parent) {
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found) {
+ char *msg = g_strdup_printf ("Field '%s' defined on
type '%s' is not a field on the target object which is of type '%s'.",
cf->name, cf->parent->name, obj->vtable->klass->name);
+ MonoException *ex = mono_get_exception_argument (NULL,
msg);
+ g_free (msg);
+ mono_raise_exception (ex);
+ }
+ }
+
t = mono_type_get_underlying_type (cf->type);
switch (t->type) {
case MONO_TYPE_STRING:
@@ -1545,8 +1568,7 @@
}
vtable = NULL;
- if (cf->type->attrs & FIELD_ATTRIBUTE_STATIC) {
- is_static = TRUE;
+ if (is_static) {
vtable = mono_class_vtable (domain, cf->parent);
if (!vtable->initialized && !(cf->type->attrs &
FIELD_ATTRIBUTE_LITERAL))
mono_runtime_class_init (vtable);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches