Imported Upstream version 6.12.0.86

Former-commit-id: 7a84ce7d08c42c458ac8e74b27186ca863315d79
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-07-10 08:44:59 +00:00
parent 92747312ea
commit 0b380204a4
812 changed files with 26901 additions and 9053 deletions

View File

@@ -645,7 +645,6 @@
<type fullname="System.Reflection.Emit.LocalBuilder" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.MethodBuilder" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.ModuleBuilder" preserve="fields" feature="sre">
<method name="Mono_GetGuid" feature="sre" />
</type>
<type fullname="System.Reflection.Emit.MonoResource" preserve="fields" feature="sre" />
<type fullname="System.Reflection.Emit.MonoWin32Resource" preserve="fields" feature="sre" />

View File

@@ -6,7 +6,7 @@ export __SECURITY_BOOTSTRAP_DB=$(topdir)/class/corlib
LIBRARY = corlib.dll
LIBRARY_NAME = mscorlib.dll
LIB_MCS_FLAGS = $(REFERENCE_SOURCES_FLAGS) $(RESOURCE_FILES:%=-resource:%)
LIB_MCS_FLAGS = $(REFERENCE_SOURCES_FLAGS) $(RESOURCE_FILES:%=-resource:%) $(UNICODECHARINFO:%=-resource:%)
USE_XTEST_REMOTE_EXECUTOR = YES
LIBRARY_WARN_AS_ERROR = yes
@@ -88,8 +88,13 @@ MANAGED_COLLATOR_RESOURCES_FILES = \
resources/collation.cjkKOlv2.bin
endif
ifdef MCS_MODE
UNICODECHARINFO = resources/charinfo.nlp
else
UNICODECHARINFO =
endif
RESOURCE_FILES = \
resources/charinfo.nlp \
$(MANAGED_COLLATOR_RESOURCES_FILES) \
LinkerDescriptor/mscorlib.xml
@@ -201,6 +206,7 @@ EXTRA_DISTFILES = \
$(RESOURCE_FILES) \
$(TEST_RESOURCE_FILES) \
$(TEST_RESOURCES:.resources=.resx) \
resources/charinfo.nlp \
LinkerDescriptor/mscorlib_test.xml
TEST_RESOURCE_FILES = \

View File

@@ -50,10 +50,10 @@ namespace Mono.Interop
private string type_name;
[MethodImplAttribute (MethodImplOptions.InternalCall)]
private extern static void AddProxy (IntPtr pItf, ComInteropProxy proxy);
private extern static void AddProxy (IntPtr pItf, ref ComInteropProxy proxy);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal extern static ComInteropProxy FindProxy (IntPtr pItf);
internal extern static void FindProxy (IntPtr pItf, ref ComInteropProxy proxy);
// Private. Objects must be created with CreateProxy.
ComInteropProxy (Type t)
@@ -68,8 +68,12 @@ namespace Mono.Interop
{
// called from unmanaged code after .ctor is invoked
// we need .ctor to create unmanaged object and thus IUnknown property value
if (FindProxy (com_object.IUnknown) == null)
AddProxy (com_object.IUnknown, this);
ComInteropProxy proxy = null;
FindProxy (com_object.IUnknown, ref proxy);
if (proxy == null) {
var self = this;
AddProxy (com_object.IUnknown, ref self);
}
else
System.Threading.Interlocked.Increment (ref ref_count);
}
@@ -92,7 +96,8 @@ namespace Mono.Interop
Guid iid = __ComObject.IID_IUnknown;
int hr = Marshal.QueryInterface (pItf, ref iid, out ppv);
Marshal.ThrowExceptionForHR (hr);
ComInteropProxy obj = FindProxy (ppv);
ComInteropProxy obj = null;
FindProxy (ppv, ref obj);
if (obj == null) {
Marshal.Release (ppv);
return new ComInteropProxy (ppv);
@@ -110,7 +115,8 @@ namespace Mono.Interop
{
IntPtr iunknown = __ComObject.CreateIUnknown (t);
ComInteropProxy proxy;
ComInteropProxy cachedProxy = FindProxy (iunknown);
ComInteropProxy cachedProxy = null;
FindProxy (iunknown, ref cachedProxy);
if (cachedProxy != null) {
// check that the COM type of the cached proxy matches
// the requested type. See 2nd part of bug #520437.

View File

@@ -27,6 +27,7 @@
//
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -255,6 +256,43 @@ namespace Mono {
}
}
static string get_breadcrumb_value (string file_prefix, string directory_str, bool clear)
{
var allfiles = Directory.GetFiles (directory_str, $"{file_prefix}_*" );
if (allfiles.Length == 0)
return string.Empty;
if (allfiles.Length > 1) {
// it's impossible to tell which breadcrumb is the last one (let's not trust filesystem timestamps)
// delete the multiple files so at least next crash can make sense
try {
Array.ForEach (allfiles, f => File.Delete (f) );
} catch (Exception) { }
return string.Empty;
}
if (clear)
File.Delete (allfiles [0]);
var filename = Path.GetFileName (allfiles [0]);
return filename.Substring (file_prefix.Length + 1);
}
static long CheckCrashReportHash (string directory_str, bool clear)
{
var value = get_breadcrumb_value ("crash_hash", directory_str, clear);
if (value == string.Empty)
return 0;
else
return Convert.ToInt64 (value, 16);
}
static string CheckCrashReportReason (string directory_str, bool clear)
{
return get_breadcrumb_value ("crash_reason", directory_str, clear);
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
static extern void AnnotateMicrosoftTelemetry_internal (IntPtr key, IntPtr val);

View File

@@ -86,14 +86,14 @@ namespace System
var src = (byte*)source;
var dst = (byte*)destination;
while (sourceBytesToCopy > int.MaxValue) {
Memcpy (dst, src, int.MaxValue);
sourceBytesToCopy -= int.MaxValue;
src += int.MaxValue;
dst += int.MaxValue;
while (sourceBytesToCopy > uint.MaxValue) {
Memmove (dst, src, uint.MaxValue);
sourceBytesToCopy -= uint.MaxValue;
src += uint.MaxValue;
dst += uint.MaxValue;
}
Memcpy (dst, src, (int) sourceBytesToCopy);
Memmove (dst, src, (uint) sourceBytesToCopy);
}
[CLSCompliantAttribute (false)]
@@ -105,14 +105,14 @@ namespace System
var src = (byte*)source;
var dst = (byte*)destination;
while (sourceBytesToCopy > int.MaxValue) {
Memcpy (dst, src, int.MaxValue);
sourceBytesToCopy -= int.MaxValue;
src += int.MaxValue;
dst += int.MaxValue;
while (sourceBytesToCopy > uint.MaxValue) {
Memmove (dst, src, uint.MaxValue);
sourceBytesToCopy -= uint.MaxValue;
src += uint.MaxValue;
dst += uint.MaxValue;
}
Memcpy (dst, src, (int) sourceBytesToCopy);
Memmove (dst, src, (uint) sourceBytesToCopy);
}
internal static unsafe void memcpy4 (byte *dest, byte *src, int size) {

View File

@@ -243,6 +243,7 @@ namespace System.Diagnostics {
}
var filename = frame.GetSecureFileName ();
#if !WASM
if (filename[0] == '<') {
var mvid = frame.GetMethod ().Module.ModuleVersionId.ToString ("N");
var aotid = GetAotId ();
@@ -252,6 +253,7 @@ namespace System.Diagnostics {
filename = string.Format ("<{0}#{1}>", mvid, aotid);
}
}
#endif
sb.AppendFormat (" in {0}:{1} ", filename, frame.GetFileLineNumber ());
}

View File

@@ -154,6 +154,9 @@ namespace System.Globalization
if (default_current_culture != null)
return default_current_culture;
if (GlobalizationMode.Invariant)
return InvariantCulture;
var locale_name = get_current_locale_name ();
CultureInfo ci = null;

View File

@@ -1066,12 +1066,6 @@ namespace System.Reflection.Emit {
return new Guid (guid);
}
// Used by mcs, the symbol writer, and mdb through reflection
internal static Guid Mono_GetGuid (ModuleBuilder mb)
{
return mb.GetModuleVersionId ();
}
public override Assembly Assembly {
get { return assemblyb; }
}

View File

@@ -82,6 +82,11 @@ namespace System.Runtime.CompilerServices
{
throw new NotImplementedException ();
}
public static ref T AsRef<T> (in T source)
{
throw new NotImplementedException ();
}
public static System.IntPtr ByteOffset<T> (ref T origin, ref T target)
{

View File

@@ -16,10 +16,10 @@
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -48,7 +48,7 @@ namespace System.Security.Principal
{
if (sddlForm == null)
throw new ArgumentNullException ("sddlForm");
buffer = ParseSddlForm (sddlForm);
}
@@ -58,42 +58,42 @@ namespace System.Security.Principal
throw new ArgumentNullException ("binaryForm");
if ((offset < 0) || (offset > binaryForm.Length - 2))
throw new ArgumentException ("offset");
fixed (byte* binaryFormPtr = binaryForm)
CreateFromBinaryForm ((IntPtr)(binaryFormPtr + offset), binaryForm.Length - offset);
}
public SecurityIdentifier (IntPtr binaryForm)
{
{
CreateFromBinaryForm (binaryForm, int.MaxValue);
}
void CreateFromBinaryForm (IntPtr binaryForm, int length)
{
{
int revision = Marshal.ReadByte (binaryForm, 0);
int numSubAuthorities = Marshal.ReadByte (binaryForm, 1);
if (revision != 1 || numSubAuthorities > 15)
throw new ArgumentException ("Value was invalid.");
if (length < (8 + (numSubAuthorities * 4)))
throw new ArgumentException ("offset");
buffer = new byte[8 + (numSubAuthorities * 4)];
Marshal.Copy (binaryForm, buffer, 0, buffer.Length);
}
public SecurityIdentifier (WellKnownSidType sidType,
SecurityIdentifier domainSid)
{
WellKnownAccount acct = WellKnownAccount.LookupByType (sidType);
if (acct == null)
throw new ArgumentException ("Unable to convert SID type: " + sidType);
if (acct.IsAbsolute) {
buffer = ParseSddlForm (acct.Sid);
} else {
if (domainSid == null)
throw new ArgumentNullException ("domainSid");
buffer = ParseSddlForm (domainSid.Value + "-" + acct.Rid);
}
}
@@ -101,11 +101,11 @@ namespace System.Security.Principal
public SecurityIdentifier AccountDomainSid {
get {
string strForm = this.Value;
// Check prefix, and ensure at least 4 sub authorities
if (!strForm.StartsWith ("S-1-5-21") || buffer[1] < 4)
return null;
// Domain is first four sub-authorities
byte[] temp = new byte[8 + (4 * 4)];
Array.Copy (buffer, 0, temp, 0, temp.Length);
@@ -121,15 +121,15 @@ namespace System.Security.Principal
public override string Value {
get {
StringBuilder s = new StringBuilder ();
ulong authority = GetSidAuthority ();
s.AppendFormat (CultureInfo.InvariantCulture, "S-1-{0}", authority);
for (byte i = 0; i < GetSidSubAuthorityCount (); ++i)
s.AppendFormat (
CultureInfo.InvariantCulture,
"-{0}", GetSidSubAuthority (i));
return s.ToString ();
}
}
@@ -140,23 +140,23 @@ namespace System.Security.Principal
| (((ulong)buffer [4]) << 24) | (((ulong)buffer [5]) << 16)
| (((ulong)buffer [6]) << 8) | (((ulong)buffer [7]) << 0);
}
byte GetSidSubAuthorityCount ()
{
return buffer [1];
}
uint GetSidSubAuthority (byte index)
{
// Note sub authorities little-endian, authority (above) is big-endian!
int offset = 8 + (index * 4);
return (((uint)buffer [offset + 0]) << 0)
| (((uint)buffer [offset + 1]) << 8)
| (((uint)buffer [offset + 2]) << 16)
| (((uint)buffer [offset + 3]) << 24);
}
// The CompareTo ordering was determined by unit test applied to MS.NET implementation,
// necessary because the CompareTo has no details in its documentation.
// (See MonoTests.System.Security.AccessControl.DiscretionaryAclTest.)
@@ -165,7 +165,7 @@ namespace System.Security.Principal
{
if (sid == null)
throw new ArgumentNullException ("sid");
int result;
if (0 != (result = GetSidAuthority ().CompareTo (sid.GetSidAuthority ()))) return result;
if (0 != (result = GetSidSubAuthorityCount ().CompareTo (sid.GetSidSubAuthorityCount ()))) return result;
@@ -192,7 +192,7 @@ namespace System.Security.Principal
throw new ArgumentNullException ("binaryForm");
if ((offset < 0) || (offset > binaryForm.Length - buffer.Length))
throw new ArgumentException ("offset");
Array.Copy (buffer, 0, binaryForm, offset, buffer.Length);
}
@@ -211,7 +211,7 @@ namespace System.Security.Principal
SecurityIdentifier domSid = AccountDomainSid;
if (domSid == null)
return false;
return domSid.Equals (sid.AccountDomainSid);
}
@@ -229,12 +229,12 @@ namespace System.Security.Principal
WellKnownAccount acct = WellKnownAccount.LookupByType (type);
if (acct == null)
return false;
string sid = Value;
if (acct.IsAbsolute)
return sid == acct.Sid;
return sid.StartsWith ("S-1-5-21", StringComparison.OrdinalIgnoreCase)
&& sid.EndsWith ("-" + acct.Rid, StringComparison.OrdinalIgnoreCase);
}
@@ -248,15 +248,15 @@ namespace System.Security.Principal
{
if (targetType == typeof(SecurityIdentifier))
return this;
if (targetType == typeof(NTAccount)) {
WellKnownAccount acct = WellKnownAccount.LookupBySid (this.Value);
if (acct == null || acct.Name == null)
throw new IdentityNotMappedException ("Unable to map SID: " + this.Value);
return new NTAccount (acct.Name);
}
throw new ArgumentException ("Unknown type.", "targetType");
}
@@ -281,11 +281,11 @@ namespace System.Security.Principal
internal string GetSddlForm()
{
string sidString = Value;
WellKnownAccount acct = WellKnownAccount.LookupBySid(sidString);
if(acct == null || acct.SddlForm == null)
return sidString;
return acct.SddlForm;
}
@@ -293,30 +293,34 @@ namespace System.Security.Principal
{
if (sddlForm.Length - pos < 2)
throw new ArgumentException("Invalid SDDL string.", "sddlForm");
string sid;
int len;
string prefix = sddlForm.Substring(pos, 2).ToUpperInvariant();
if (prefix == "S-")
{
// Looks like a SID, try to parse it.
int endPos = pos;
char ch = Char.ToUpperInvariant(sddlForm[endPos]);
while (ch == 'S' || ch == '-' || ch == 'X'
|| (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'F')) {
++endPos;
ch = Char.ToUpperInvariant(sddlForm[endPos]);
}
if (ch == ':' && sddlForm[endPos - 1] == 'D') {
endPos--;
}
sid = sddlForm.Substring(pos, endPos - pos);
len = endPos - pos;
} else {
sid = prefix;
len = 2;
}
SecurityIdentifier ret = new SecurityIdentifier(sid);
pos += len;
return ret;
@@ -325,7 +329,7 @@ namespace System.Security.Principal
private static byte[] ParseSddlForm (string sddlForm)
{
string sid = sddlForm;
// If only 2 characters long, can't be a full SID string - so assume
// it's an attempted alias. Do that conversion first.
if(sddlForm.Length == 2) {
@@ -341,20 +345,20 @@ namespace System.Security.Principal
sid = acct.Sid;
}
string[] elements = sid.ToUpperInvariant ().Split ('-');
int numSubAuthorities = elements.Length - 3;
if (elements.Length < 3 || elements[0] != "S" || numSubAuthorities > 15)
throw new ArgumentException ("Value was invalid.");
if (elements[1] != "1")
throw new ArgumentException ("Only SIDs with revision 1 are supported");
byte[] buffer = new byte[8 + (numSubAuthorities * 4)];
buffer[0] = 1;
buffer[1] = (byte)numSubAuthorities;
ulong authority;
if (!TryParseAuthority (elements[2], out authority))
throw new ArgumentException ("Value was invalid.");
@@ -364,14 +368,14 @@ namespace System.Security.Principal
buffer[5] = (byte)((authority >> 16) & 0xFF);
buffer[6] = (byte)((authority >> 8) & 0xFF);
buffer[7] = (byte)((authority >> 0) & 0xFF);
for (int i = 0; i < numSubAuthorities; ++i) {
uint subAuthority;
if (!TryParseSubAuthority (elements[i + 3],
out subAuthority))
throw new ArgumentException ("Value was invalid.");
// Note sub authorities little-endian!
int offset = 8 + (i * 4);
buffer[offset + 0] = (byte)(subAuthority >> 0);
@@ -379,7 +383,7 @@ namespace System.Security.Principal
buffer[offset + 2] = (byte)(subAuthority >> 16);
buffer[offset + 3] = (byte)(subAuthority >> 24);
}
return buffer;
}
@@ -412,4 +416,3 @@ namespace System.Security.Principal
}
}
}

View File

@@ -55,8 +55,7 @@ namespace System.Threading {
IntPtr native_handle; // used only on Win32
/* accessed only from unmanaged code */
private IntPtr name_chars;
private IntPtr name_generation;
private int name_free;
private int name_free; // bool
private int name_length;
private ThreadState state;
private object abort_exc;
@@ -307,7 +306,13 @@ namespace System.Threading {
#endif
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static Thread GetCurrentThread ();
private extern static void GetCurrentThread_icall (ref Thread thread);
private static Thread GetCurrentThread () {
Thread thread = null;
GetCurrentThread_icall (ref thread);
return thread;
}
public static Thread CurrentThread {
[ReliabilityContract (Consistency.WillNotCorruptState, Cer.MayFail)]

View File

@@ -186,7 +186,11 @@ namespace System
{
try {
// TODO: Should use __ConsoleStream from reference sources
return new FileStream (handle, access, false, bufferSize, false, true);
var stream = new FileStream (handle, access, false, bufferSize, false, true);
// Don't run the finalizer on the underlying stream so that System.WriteLine can be
// called inside a finalizer during shutdown or domain unload.
GC.SuppressFinalize (stream);
return stream;
} catch (IOException) {
return Stream.Null;
}

View File

@@ -67,7 +67,7 @@ namespace System
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
internal static extern object[] GetCustomAttributesInternal (ICustomAttributeProvider obj, Type attributeType, bool pseudoAttrs);
internal static extern Attribute[] GetCustomAttributesInternal (ICustomAttributeProvider obj, Type attributeType, bool pseudoAttrs);
internal static object[] GetPseudoCustomAttributes (ICustomAttributeProvider obj, Type attributeType) {
object[] pseudoAttrs = null;
@@ -134,7 +134,7 @@ namespace System
if (!inheritedOnly) {
object[] pseudoAttrs = GetPseudoCustomAttributes (obj, attributeType);
if (pseudoAttrs != null) {
object[] res = new object [attrs.Length + pseudoAttrs.Length];
object[] res = new Attribute [attrs.Length + pseudoAttrs.Length];
System.Array.Copy (attrs, res, attrs.Length);
System.Array.Copy (pseudoAttrs, 0, res, attrs.Length, pseudoAttrs.Length);
return res;

View File

@@ -17,10 +17,10 @@ namespace MonoTests.System.Security.AccessControl {
private void CheckSddlConstructor (string sddl, byte[] expectedBinary)
{
RawSecurityDescriptor sd = new RawSecurityDescriptor (sddl);
Assert.That (sd.BinaryLength, Is.GreaterThanOrEqualTo (0));
byte[] buffer = new byte[sd.BinaryLength];
sd.GetBinaryForm (buffer, 0);
Assert.AreEqual (expectedBinary, buffer);
}
@@ -28,7 +28,7 @@ namespace MonoTests.System.Security.AccessControl {
private void CheckBinaryConstructor (string expectedSddl, byte[] binary)
{
RawSecurityDescriptor sd = new RawSecurityDescriptor (binary, 0);
Assert.AreEqual (sd.BinaryLength, binary.Length);
Assert.AreEqual (expectedSddl, sd.GetSddlForm (AccessControlSections.All));
}
@@ -36,10 +36,10 @@ namespace MonoTests.System.Security.AccessControl {
private void CheckRoundTrip (string sddl)
{
RawSecurityDescriptor sd = new RawSecurityDescriptor (sddl);
byte[] buffer = new byte[sd.BinaryLength];
sd.GetBinaryForm (buffer, 0);
sd = new RawSecurityDescriptor (buffer, 0);
Assert.AreEqual (sddl, sd.GetSddlForm (AccessControlSections.All));
}
@@ -69,7 +69,7 @@ namespace MonoTests.System.Security.AccessControl {
CheckSddlConstructor ("G:BAO:BUD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)", sdBinary);
CheckSddlConstructor ("G:BAD:(A; ;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)O:BU", sdBinary);
CheckSddlConstructor ("O:buG:baD:(a;;rpwpccdclcswrcwdwoga;;;s-1-0-0)", sdBinary);
sdBinary = new byte[] {
0x01, 0x00, 0x00, 0x80, 0x14, 0x00, 0x00, 0x00, 0x24, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -78,7 +78,7 @@ namespace MonoTests.System.Security.AccessControl {
0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x20, 0x02,
0x00, 0x00 };
CheckSddlConstructor ("O:BUG:BA", sdBinary);
sdBinary = new byte[] {
0x01, 0x00, 0x04, 0x80, 0x14, 0x00, 0x00, 0x00, 0x24, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
@@ -116,7 +116,7 @@ namespace MonoTests.System.Security.AccessControl {
0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x20, 0x02,
0x00, 0x00 };
CheckBinaryConstructor ("O:BUG:BA", sdBinary);
sdBinary = new byte[] {
0x01, 0x00, 0x04, 0x80, 0x14, 0x00, 0x00, 0x00, 0x24, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
@@ -147,7 +147,7 @@ namespace MonoTests.System.Security.AccessControl {
0x01, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
Assert.AreEqual (sdBinary, buffer);
// Check unsetting DACL-present flag on SD with DACL
sd = new RawSecurityDescriptor ("O:BUG:BAD:(A;;RPWPCCDCLCSWRCWDWOGA;;;S-1-0-0)");
Assert.AreEqual (80, sd.BinaryLength);
@@ -175,7 +175,7 @@ namespace MonoTests.System.Security.AccessControl {
sd.DiscretionaryAcl = new RawAcl (1, 0);
sd.SystemAcl = new RawAcl (1, 0);
sd.SetFlags (sd.ControlFlags | ControlFlags.DiscretionaryAclPresent | ControlFlags.SystemAclPresent);
// Empty ACL form
byte[] buffer = new byte[sd.BinaryLength];
sd.GetBinaryForm (buffer, 0);
@@ -188,7 +188,7 @@ namespace MonoTests.System.Security.AccessControl {
0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00 };
Assert.AreEqual (sdBinary, buffer);
// Add an ACE to the DACL
SecurityIdentifier builtInAdmins = new SecurityIdentifier (WellKnownSidType.BuiltinAdministratorsSid, null);
CommonAce ace = new CommonAce (AceFlags.None, AceQualifier.AccessAllowed, 0x7FFFFFFF, builtInAdmins, false, null);
@@ -207,7 +207,7 @@ namespace MonoTests.System.Security.AccessControl {
0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x20, 0x02,
0x00, 0x00 };
Assert.AreEqual (sdBinary, buffer);
// This time with an Object ACE
ObjectAce objectAce = new ObjectAce (AceFlags.Inherited, AceQualifier.AccessAllowed, 0x12345678, builtInAdmins, ObjectAceFlags.ObjectAceTypePresent | ObjectAceFlags.InheritedObjectAceTypePresent, new Guid ("189c0dc7-b849-4dea-93a5-6d4cb8857a5c"), new Guid ("53b4a3d4-fe39-468b-bc60-b4fcba772fa5"), false, null);
sd.DiscretionaryAcl = new RawAcl (2, 0);
@@ -236,37 +236,37 @@ namespace MonoTests.System.Security.AccessControl {
{
RawSecurityDescriptor sd = new RawSecurityDescriptor ("");
Assert.AreEqual ("", sd.GetSddlForm (AccessControlSections.All));
// Ask for part of SD that isn't represented
sd.Owner = new SecurityIdentifier (WellKnownSidType.BuiltinUsersSid, null);
sd.Group = new SecurityIdentifier (WellKnownSidType.BuiltinAdministratorsSid, null);
Assert.AreEqual ("", sd.GetSddlForm (AccessControlSections.Access));
// Empty ACL form
sd.DiscretionaryAcl = new RawAcl (2, 0);
sd.SystemAcl = new RawAcl (1, 0);
sd.SetFlags (sd.ControlFlags | ControlFlags.DiscretionaryAclPresent | ControlFlags.SystemAclPresent);
Assert.AreEqual ("O:BUG:BAD:S:", sd.GetSddlForm (AccessControlSections.All));
// Add an ACE to the DACL
SecurityIdentifier builtInAdmins = new SecurityIdentifier (WellKnownSidType.BuiltinAdministratorsSid, null);
CommonAce ace = new CommonAce (AceFlags.None, AceQualifier.AccessAllowed, 0x7FFFFFFF, builtInAdmins, false, null);
sd.DiscretionaryAcl.InsertAce (0, ace);
Assert.AreEqual ("O:BUG:BAD:(A;;0x7fffffff;;;BA)S:", sd.GetSddlForm (AccessControlSections.All));
// Add second ACE to the DACL
SecurityIdentifier randomUser = new SecurityIdentifier ("S-1-5-21-324-23423-234-334");
ace = new CommonAce (AceFlags.Inherited | AceFlags.ContainerInherit, AceQualifier.AccessDenied, 0x12345678, randomUser, true, null);
sd.DiscretionaryAcl.InsertAce (0, ace);
Assert.AreEqual ("O:BUD:(XD;CIID;0x12345678;;;S-1-5-21-324-23423-234-334)(A;;0x7fffffff;;;BA)", sd.GetSddlForm (AccessControlSections.Owner | AccessControlSections.Access));
// DACL & SACL flags
sd.SetFlags (sd.ControlFlags | ControlFlags.DiscretionaryAclProtected | ControlFlags.DiscretionaryAclAutoInherited | ControlFlags.DiscretionaryAclAutoInheritRequired | ControlFlags.SystemAclAutoInherited);
sd.DiscretionaryAcl = new RawAcl (1, 0);
ace = new CommonAce (AceFlags.None, AceQualifier.AccessAllowed, 0x7FFFFFFF, builtInAdmins, false, null);
sd.DiscretionaryAcl.InsertAce (0, ace);
Assert.AreEqual ("O:BUG:BAD:PARAI(A;;0x7fffffff;;;BA)S:AI", sd.GetSddlForm (AccessControlSections.All));
sd.SetFlags (sd.ControlFlags | ControlFlags.ServerSecurity | ControlFlags.DiscretionaryAclDefaulted);
Assert.AreEqual ("O:BUG:BAD:PARAI(A;;0x7fffffff;;;BA)S:AI", sd.GetSddlForm (AccessControlSections.All));
}
@@ -281,6 +281,7 @@ namespace MonoTests.System.Security.AccessControl {
CheckRoundTrip ("O:SYG:BAD:(A;;0x12019f;;;SY)(A;;0x12019f;;;BA)");
CheckRoundTrip ("O:SYG:BAD:(A;OICINPIOID;0x12019f;;;SY)");
CheckRoundTrip ("O:SYG:BAS:(AU;SAFA;0x12019f;;;SY)");
CheckRoundTrip ("O:S-1-5-21-1356517589-3987021482-2501375073-1001G:S-1-5-21-1356517589-3987021482-2501375073-513D:(A;;FA;;;SY)(A;;FA;;;BA)(A;;FA;;;S-1-5-21-1356517589-3987021482-2501375073-1001)");
}
}
}

View File

@@ -1313,6 +1313,9 @@ namespace MonoTests.System.Threading
Thread.VolatileWrite (ref v3, double.MaxValue);
Assert.AreEqual (v3, double.MaxValue);
object o = "ABC";
Assert.AreEqual ("ABC", Thread.VolatileRead (ref o));
float v4 = 1;
Thread.VolatileWrite (ref v4, float.MaxValue);
Assert.AreEqual (v4, float.MaxValue);

View File

@@ -297,5 +297,27 @@ namespace MonoTests.System {
Assert.AreEqual (0xAABB0000, b, "#2");
}
}
[Test] // https://github.com/mono/mono/issues/18516
public unsafe void MemoryCopy_Overlapped ()
{
byte [] buffer = new byte [5];
for (int i = 0; i < buffer.Length; i++)
buffer [i] = (byte)i;
int bytesToCopy = buffer.Length - 1;
fixed (byte* pBuffer = buffer)
Buffer.MemoryCopy (pBuffer, pBuffer + 1, buffer.Length - 1, bytesToCopy);
bool failed = false;
for (int i = 0; i < buffer.Length; i++)
{
byte expectedByte = (byte)(i == 0 ? 0 : i - 1);
if (buffer [i] != expectedByte)
failed = true;
}
Assert.IsFalse (failed);
}
}
}

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
d8d8021a5ca1bc353a5abb4cc17334448231e895
85ce092a17302d8295982b34ada18ebd6ca4d14e