From 5619527a273ff4fdebd5ca684b3923b74b1b25fb Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Thu, 1 Apr 2010 13:19:02 +0000 Subject: [PATCH] 2010-04-01 Sebastien Pouliot * method-to-ir.c (ensure_method_is_allowed_to_[access_field| call_method]): Delegate the actual work in security-core-clr.c to ease code sharing. svn path=/trunk/mono/; revision=154638 --- mono/mini/ChangeLog | 6 ++++++ mono/mini/method-to-ir.c | 28 ++++++---------------------- 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/mono/mini/ChangeLog b/mono/mini/ChangeLog index b3c559932d7..86c209e048e 100755 --- a/mono/mini/ChangeLog +++ b/mono/mini/ChangeLog @@ -1,3 +1,9 @@ +2010-04-01 Sebastien Pouliot + + * method-to-ir.c (ensure_method_is_allowed_to_[access_field| + call_method]): Delegate the actual work in security-core-clr.c + to ease code sharing. + 2010-04-01 Zoltan Varga * decompose.c (mono_decompose_opcode): Set the cfg exception if the unsupported diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c index d356f3abafb..def7a32bf98 100644 --- a/mono/mini/method-to-ir.c +++ b/mono/mini/method-to-ir.c @@ -4887,36 +4887,20 @@ static void ensure_method_is_allowed_to_access_field (MonoCompile *cfg, MonoMethod *caller, MonoClassField *field, MonoBasicBlock *bblock, unsigned char *ip) { - /* there's no restriction to access Transparent or SafeCritical fields, so we only check calls to Critical methods */ - if (mono_security_core_clr_class_level (mono_field_get_parent (field)) != MONO_SECURITY_CORE_CLR_CRITICAL) - return; - /* we can't get the coreclr security level on wrappers since they don't have the attributes */ - caller = get_original_method (caller); - if (!caller) - return; - - /* caller is Critical! only SafeCritical and Critical callers can access the field, so we throw if caller is Transparent */ - if (mono_security_core_clr_method_level (caller, TRUE) == MONO_SECURITY_CORE_CLR_TRANSPARENT) - emit_throw_exception (cfg, mono_get_exception_field_access ()); + MonoException *ex = mono_security_core_clr_is_field_access_allowed (get_original_method (caller), field); + if (ex) + emit_throw_exception (cfg, ex); } static void ensure_method_is_allowed_to_call_method (MonoCompile *cfg, MonoMethod *caller, MonoMethod *callee, MonoBasicBlock *bblock, unsigned char *ip) { - /* there's no restriction to call Transparent or SafeCritical code, so we only check calls to Critical methods */ - if (mono_security_core_clr_method_level (callee, TRUE) != MONO_SECURITY_CORE_CLR_CRITICAL) - return; - /* we can't get the coreclr security level on wrappers since they don't have the attributes */ - caller = get_original_method (caller); - if (!caller) - return; - - /* caller is Critical! only SafeCritical and Critical callers can call it, so we throw if the caller is Transparent */ - if (mono_security_core_clr_method_level (caller, TRUE) == MONO_SECURITY_CORE_CLR_TRANSPARENT) - emit_throw_exception (cfg, mono_get_exception_method_access ()); + MonoException *ex = mono_security_core_clr_is_call_allowed (get_original_method (caller), callee); + if (ex) + emit_throw_exception (cfg, ex); } /* -- 2.25.1