Imported Upstream version 4.2.0.179

Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
Xamarin Public Jenkins
2015-08-26 07:17:56 -04:00
committed by Jo Shields
parent aa7da660d6
commit c042cd0c52
7507 changed files with 90259 additions and 657307 deletions

View File

@ -234,34 +234,6 @@ namespace System.Security {
// special case when directly called from CodeAccessPermission.Demand
_ignored = new bool [list.Count];
}
ArrayList frames = SecurityFrame.GetStack (skip);
if ((frames != null) && (frames.Count > 0)) {
SecurityFrame first = ((SecurityFrame) frames [0]);
current = first.Assembly;
domain = first.Domain;
// skip ourself, Demand and other security runtime methods
foreach (SecurityFrame sf in frames) {
if (ProcessFrame (sf, ref current, ref domain)) {
if (AllIgnored ())
return; // reached Assert
}
}
SecurityFrame last = ((SecurityFrame) frames [frames.Count - 1]);
CheckAssembly (current, last);
CheckAppDomain (domain, last);
}
// Is there a CompressedStack to handle ?
CompressedStack stack = Thread.CurrentThread.GetCompressedStack ();
if ((stack != null) && !stack.IsEmpty ()) {
foreach (SecurityFrame frame in stack.List) {
if (ProcessFrame (frame, ref current, ref domain)) {
if (AllIgnored ())
return; // reached Assert
}
}
}
}
[MonoTODO ("CAS support is experimental (and unsupported). Imperative mode is not implemented.")]
@ -681,65 +653,6 @@ namespace System.Security {
return true;
}
internal bool ProcessFrame (SecurityFrame frame, ref Assembly current, ref AppDomain domain)
{
if (IsUnrestricted ()) {
// we request unrestricted
if (frame.Deny != null) {
// but have restrictions (some denied permissions)
CodeAccessPermission.ThrowSecurityException (this, "Deny", frame, SecurityAction.Demand, null);
} else if ((frame.PermitOnly != null) && !frame.PermitOnly.IsUnrestricted ()) {
// but have restrictions (only some permitted permissions)
CodeAccessPermission.ThrowSecurityException (this, "PermitOnly", frame, SecurityAction.Demand, null);
}
}
// skip next steps if no Assert, Deny or PermitOnly are present
if (frame.HasStackModifiers) {
for (int i = 0; i < list.Count; i++) {
CodeAccessPermission cap = (CodeAccessPermission) list [i];
if (cap.ProcessFrame (frame)) {
_ignored [i] = true; // asserted
if (AllIgnored ())
return true; // no more, abort stack walk!
}
}
}
// however the "final" grant set is resolved by assembly, so
// there's no need to check it every time (just when we're
// changing assemblies between frames).
if (frame.Assembly != current) {
CheckAssembly (current, frame);
current = frame.Assembly;
}
if (frame.Domain != domain) {
CheckAppDomain (domain, frame);
domain = frame.Domain;
}
return false;
}
internal void CheckAssembly (Assembly a, SecurityFrame frame)
{
IPermission p = SecurityManager.CheckPermissionSet (a, this, false);
if (p != null) {
CodeAccessPermission.ThrowSecurityException (this, "Demand failed assembly permissions checks.",
frame, SecurityAction.Demand, p);
}
}
internal void CheckAppDomain (AppDomain domain, SecurityFrame frame)
{
IPermission p = SecurityManager.CheckPermissionSet (domain, this);
if (p != null) {
CodeAccessPermission.ThrowSecurityException (this, "Demand failed appdomain permissions checks.",
frame, SecurityAction.Demand, p);
}
}
// 2.0 metadata format
internal static PermissionSet CreateFromBinaryFormat (byte[] data)