Imported Upstream version 6.6.0.89

Former-commit-id: b39a328747c2f3414dc52e009fb6f0aa80ca2492
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2019-09-24 08:53:40 +00:00
parent cf815e07e0
commit 95fdb59ea6
2556 changed files with 138145 additions and 47453 deletions

View File

@@ -27,7 +27,7 @@ XTEST_RESOURCE_FILES = \
Test/TestData/testservereku.contoso.com.pfx
USE_XTEST_REMOTE_EXECUTOR = YES
XTEST_LIB_REFS = System System.Core System.Net Facades/System.Threading.Tasks Facades/System.Runtime.InteropServices.RuntimeInformation System.Net.Http
XTEST_LIB_REFS = System System.Core Facades/System.Threading.Tasks Facades/System.Runtime.InteropServices.RuntimeInformation System.Net.Http
LIB_MCS_FLAGS = -d:COREFX -d:CONFIGURATION_2_0 -d:SYSTEM_NET_PRIMITIVES_DLL -d:XML_DEP -d:SECURITY_DEP $(REFERENCE_SOURCES_FLAGS) -unsafe $(RESOURCE_FILES:%=-resource:%) -nowarn:436
XTEST_MCS_FLAGS += $(XTEST_RESOURCE_FILES:%=-resource:%)

View File

@@ -31,9 +31,11 @@ extern alias MonoSecurity;
#if MONO_SECURITY_ALIAS
using MX = MonoSecurity::Mono.Security.X509;
using MonoSecurity::Mono.Security.Cryptography;
using MonoSecurity::Mono.Security.Authenticode;
#else
using MX = Mono.Security.X509;
using Mono.Security.Cryptography;
using Mono.Security.Authenticode;
#endif
using System;
@@ -86,9 +88,13 @@ namespace Mono.Btls
try {
ImportPkcs12 (data, null);
} catch {
string msg = Locale.GetText ("Unable to decode certificate.");
// inner exception is the original (not second) exception
throw new CryptographicException (msg, e);
try {
ImportAuthenticode (data);
} catch {
string msg = Locale.GetText ("Unable to decode certificate.");
// inner exception is the original (not second) exception
throw new CryptographicException (msg, e);
}
}
}
} else {
@@ -101,9 +107,13 @@ namespace Mono.Btls
// fix bug #79028
Import (data);
} catch {
string msg = Locale.GetText ("Unable to decode certificate.");
// inner exception is the original (not second) exception
throw new CryptographicException (msg, e);
try {
ImportAuthenticode (data);
} catch {
string msg = Locale.GetText ("Unable to decode certificate.");
// inner exception is the original (not second) exception
throw new CryptographicException (msg, e);
}
}
}
}
@@ -188,7 +198,14 @@ namespace Mono.Btls
set {
if (nativePrivateKey != null)
nativePrivateKey.Dispose ();
nativePrivateKey = null;
try {
// FIXME: there doesn't seem to be a public API to check whether it actually
// contains a private key (apart from RSAManaged.PublicOnly).
if (value != null)
nativePrivateKey = MonoBtlsKey.CreateFromRSAPrivateKey ((RSA)value);
} catch {
nativePrivateKey = null;
}
}
}
@@ -261,6 +278,14 @@ namespace Mono.Btls
}
}
void ImportAuthenticode (byte[] data)
{
if (data != null) {
AuthenticodeDeformatter ad = new AuthenticodeDeformatter (data);
Import (ad.SigningCertificate.RawData);
}
}
public override bool Verify (X509Certificate2 thisCertificate)
{
using (var chain = new MonoBtlsX509Chain ()) {

View File

@@ -26,8 +26,12 @@
#if MONO_SECURITY_ALIAS
extern alias MonoSecurity;
using MonoSecurity::Mono.Security;
using MonoSecurity::Mono.Security.Authenticode;
#else
using Mono.Security;
#if !MONOTOUCH_WATCH
using Mono.Security.Authenticode;
#endif
#endif
using System;
@@ -126,7 +130,17 @@ namespace Mono
return X509ContentType.Cert;
}
return X509ContentType.Unknown;
#if MONOTOUCH_WATCH
return X509ContentType.Unknown;
#else
try {
AuthenticodeDeformatter ad = new AuthenticodeDeformatter (rawData);
return X509ContentType.Authenticode;
} catch {
return X509ContentType.Unknown;
}
#endif
}
public X509ContentType GetCertContentType (string fileName)

View File

@@ -274,7 +274,13 @@ namespace System.Diagnostics {
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern void GetVersionInfo_internal(string fileName);
private unsafe extern void GetVersionInfo_icall (char *fileName, int fileName_length);
private unsafe void GetVersionInfo_internal (string fileName)
{
fixed (char* fixed_filename = fileName)
GetVersionInfo_icall (fixed_filename, fileName?.Length ?? 0);
}
public static FileVersionInfo GetVersionInfo (string fileName)
{

View File

@@ -141,14 +141,14 @@ namespace System.Diagnostics
* element 0.
*/
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern ProcessModule[] GetModules_internal(IntPtr handle);
private extern ProcessModule[] GetModules_icall (IntPtr handle);
ProcessModule[] GetModules_internal (SafeProcessHandle handle)
{
bool release = false;
try {
handle.DangerousAddRef (ref release);
return GetModules_internal (handle.DangerousGetHandle ());
return GetModules_icall (handle.DangerousGetHandle ());
} finally {
if (release)
handle.DangerousRelease ();
@@ -323,14 +323,14 @@ namespace System.Diagnostics
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static string ProcessName_internal(IntPtr handle);
private extern static string ProcessName_icall (IntPtr handle);
static string ProcessName_internal(SafeProcessHandle handle)
{
bool release = false;
try {
handle.DangerousAddRef (ref release);
return ProcessName_internal (handle.DangerousGetHandle ());
return ProcessName_icall (handle.DangerousGetHandle ());
} finally {
if (release)
handle.DangerousRelease ();

View File

@@ -1,103 +0,0 @@
//
// System.Diagnostics.ProcessStartInfo.cs
//
// Authors:
// Dick Porter (dick@ximian.com)
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2002 Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// 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
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using Microsoft.Win32;
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.IO;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Runtime.InteropServices;
namespace System.Diagnostics
{
[StructLayout (LayoutKind.Sequential)]
public sealed partial class ProcessStartInfo
{
internal bool HaveEnvVars {
get { return (environmentVariables != null); }
}
Collection<string> _argumentList;
public Collection<string> ArgumentList {
get {
if (_argumentList == null) {
_argumentList = new Collection<string>();
}
return _argumentList;
}
}
public Encoding StandardInputEncoding { get; set; }
static readonly string [] empty = new string [0];
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden), Browsable (false)]
public string[] Verbs {
get {
#if MOBILE
return empty;
#else
switch (System.Environment.OSVersion.Platform) {
case (PlatformID)4:
case (PlatformID)6:
case (PlatformID)128:
return empty; // no verb on non-Windows
default:
string ext = String.IsNullOrEmpty (fileName) ? null : Path.GetExtension (fileName);
if (ext == null)
return empty;
RegistryKey rk = null, rk2 = null, rk3 = null;
try {
rk = Registry.ClassesRoot.OpenSubKey (ext);
string k = rk != null ? rk.GetValue (null) as string : null;
rk2 = k != null ? Registry.ClassesRoot.OpenSubKey (k) : null;
rk3 = rk2 != null ? rk2.OpenSubKey ("shell") : null;
return rk3 != null ? rk3.GetSubKeyNames () : null;
} finally {
if (rk3 != null)
rk3.Close ();
if (rk2 != null)
rk2.Close ();
if (rk != null)
rk.Close ();
}
}
#endif
}
}
}
}

View File

@@ -145,7 +145,10 @@ namespace System.IO.Compression
internal int ReadCore (Span<byte> destination)
{
throw new NotImplementedException ();
var buffer = new byte [destination.Length];
int count = Read(buffer, 0, buffer.Length);
buffer.AsSpan(0, count).CopyTo(destination);
return count;
}
public override int Read (byte[] array, int offset, int count)
@@ -185,7 +188,7 @@ namespace System.IO.Compression
internal void WriteCore (ReadOnlySpan<byte> source)
{
throw new NotImplementedException ();
Write (source.ToArray (), 0, source.Length);
}
public override void Write (byte[] array, int offset, int count)
@@ -554,7 +557,7 @@ namespace System.IO.Compression
{
throw new PlatformNotSupportedException ();
}
#elif MONOTOUCH || MONODROID
#elif MONOTOUCH || MONODROID || WASM
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern IntPtr CreateZStream (int compress, bool gzip, IntPtr feeder, IntPtr data);

View File

@@ -61,7 +61,7 @@ namespace System.IO {
SearchPattern2 pattern;
bool disposed;
string mangledFilter;
static IFileWatcher watcher;
IFileWatcher watcher;
object watcher_handle;
static object lockobj = new object ();

View File

@@ -971,8 +971,6 @@ namespace System.Net.Sockets
e.socket_async_result.Complete (exc, true);
return false;
}
return true;
}
public static void CancelConnectAsync (SocketAsyncEventArgs e)
@@ -2952,6 +2950,15 @@ namespace System.Net.Sockets
return false;
#endif
}
internal void ReplaceHandleIfNecessaryAfterFailedConnect ()
{
/*
* This is called from `DualSocketMultipleConnectAsync.GetNextAddress(out Socket)`
* and `SingleSocketMultipleConnectAsync.GetNextAddress(out Socket)` when using
* the CoreFX version of `MultipleConnectAsync`.
*/
}
}
}

View File

@@ -213,6 +213,13 @@ namespace System.Net.Sockets
handler (e.current_socket, e);
}
internal void CopyBufferFrom (SocketAsyncEventArgs source)
{
Buffer = source.Buffer;
Offset = source.Offset;
Count = source.Count;
}
public void SetBuffer (int offset, int count)
{
SetBuffer (Buffer, offset, count);

View File

@@ -33,10 +33,14 @@
extern alias MonoSecurity;
using MonoSecurity::Mono.Security;
using MonoSecurity::Mono.Security.Cryptography;
using MonoSecurity::Mono.Security.Authenticode;
using MX = MonoSecurity::Mono.Security.X509;
#else
using Mono.Security;
using Mono.Security.Cryptography;
#if !MONOTOUCH_WATCH
using Mono.Security.Authenticode;
#endif
using MX = Mono.Security.X509;
#endif
@@ -97,6 +101,15 @@ namespace System.Security.Cryptography.X509Certificates
_cert = new MX.X509Certificate (rawData);
break;
#if !MONOTOUCH_WATCH
case X509ContentType.Authenticode:
AuthenticodeDeformatter ad = new AuthenticodeDeformatter (rawData);
_cert = ad.SigningCertificate;
if (_cert == null)
goto default;
break;
#endif
default:
string msg = Locale.GetText ("Unable to decode certificate.");
throw new CryptographicException (msg);

View File

@@ -11,6 +11,7 @@
using NUnit.Framework;
using System;
using System.IO;
using System.Reflection;
using MonoTests.Helpers;
@@ -95,7 +96,86 @@ namespace MonoTests.System.IO
fw.Path = "*";
}
}
[Test]
[Category ("NotOnMac")] // creates resource exhaustion issues
public void LargeNumberOfInstances ()
{
using (var tmp = new TempDirectory ()) {
var watchers = new FileSystemWatcher [256];
for (int x = 0; x < watchers.Length; x++)
{
watchers[x] = new FileSystemWatcher (tmp.Path, "*");
watchers[x].EnableRaisingEvents = true;
}
}
}
[Test]
public void CreateTwoAndDispose ()
{
// Create two FSW instances and dispose them. Verify
// that the backend IFileWatcher's Dispose
// (watcher_handle) method got called.
// FIXME: This only works for the
// CoreFXFileSystemWatcherProxy not the other backends.
using (var tmp = new TempDirectory ()) {
// have to use reflection to poke at the private fields of FileSystemWatcher.
var watcherField = typeof (FileSystemWatcher).GetField ("watcher", BindingFlags.Instance | BindingFlags.NonPublic);
Assert.IsNotNull (watcherField);
var watcherHandleField = typeof (FileSystemWatcher).GetField ("watcher_handle", BindingFlags.Instance | BindingFlags.NonPublic);
Assert.IsNotNull (watcherHandleField);
var proxyType = typeof (FileSystemWatcher).Assembly.GetType ("System.IO.CoreFXFileSystemWatcherProxy");
Assert.IsNotNull (proxyType);
var fsw1 = new FileSystemWatcher (tmp.Path, "*");
var fsw2 = new FileSystemWatcher (tmp.Path, "*");
object handle1 = null;
object handle2 = null;
// using "using" to ensure that Dispose gets called even if we throw an exception
using (var fsw11 = fsw1)
using (var fsw22 = fsw2) {
// at this point watcher and watcher_handle should be set
var watcher = watcherField.GetValue (fsw1);
Assert.IsNotNull (watcher);
if (!proxyType.IsAssignableFrom (watcher.GetType ()))
Assert.Ignore ("Testing only CoreFXFileSystemWatcherProxy FSW backend");
handle1 = watcherHandleField.GetValue (fsw1);
handle2 = watcherHandleField.GetValue (fsw2);
Assert.IsNotNull (handle1);
Assert.IsNotNull (handle2);
}
// Dispose was called, now watcher_handle should be null
Assert.IsNull (watcherHandleField.GetValue (fsw1));
Assert.IsNull (watcherHandleField.GetValue (fsw2));
// and moreover, the CoreFXFileSystemWatcherProxy shouldn't have entries for either handle1 or handle2
var proxyTypeInternalMapField = proxyType.GetField ("internal_map", BindingFlags.Static | BindingFlags.NonPublic);
Assert.IsNotNull (proxyTypeInternalMapField);
var internal_map = proxyTypeInternalMapField.GetValue (null)
as global::System.Collections.Generic.IDictionary<object, global::System.IO.CoreFX.FileSystemWatcher>;
Assert.IsNotNull (internal_map);
// This pair are the critical checks: after we call Dispose on fsw1 and fsw2, the
// backend's internal map shouldn't have anything keyed on handle1 and handle2.
// Therefore System.IO.CoreFX.FileSystemWatcher instances will be disposed of, too.
Assert.IsFalse (internal_map.ContainsKey (handle1));
Assert.IsFalse (internal_map.ContainsKey (handle2));
}
}
}
}
#endif
#endif

View File

@@ -1 +1 @@
2ece09a6bcbc8bd2bc7fba916be03eb093a31b70
0881431c7a6dbf19a843dbfb0b2a53abf5635098

View File

@@ -16,7 +16,6 @@ System.Diagnostics/MonitoringDescriptionAttribute.cs
System.Diagnostics/Process.cs
System.Diagnostics/ProcessModule.cs
System.Diagnostics/ProcessPriorityClass.cs
System.Diagnostics/ProcessStartInfo.cs
System.Diagnostics/ProcessThread.cs
System.Diagnostics/ProcessWindowStyle.cs
System.Diagnostics/Stopwatch.cs
@@ -662,7 +661,7 @@ ReferenceSources/Win32Exception.cs
../referencesource/System/net/System/Net/SecureProtocols/AuthenticatedStream.cs
../referencesource/System/net/System/Net/SecureProtocols/NegotiateEnumTypes.cs
../referencesource/System/net/System/Net/Sockets/_MultipleConnectAsync.cs
../../../external/corefx/src/System.Net.Sockets/src/System/Net/Sockets/MultipleConnectAsync.cs
../referencesource/System/net/System/Net/Sockets/AddressFamily.cs
../referencesource/System/net/System/Net/Sockets/IOControlCode.cs
../referencesource/System/net/System/Net/Sockets/IPPacketInformation.cs

View File

@@ -0,0 +1 @@
#include winaot_System.dll.exclude.sources

View File

@@ -0,0 +1,6 @@
#include winaot_System.dll.sources
../../../external/corefx/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs
../../../external/corefx/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/CompiledRegexRunner.cs
../../../external/corefx/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/CompiledRegexRunnerFactory.cs
../../../external/corefx/src/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexLWCGCompiler.cs

View File

@@ -0,0 +1 @@
#include winaot_System_test.dll.exclude.sources

View File

@@ -0,0 +1 @@
#include winaot_System_test.dll.sources

View File

@@ -1,3 +1,6 @@
#include corefx.unix.sources
#include unix_networkinfo.sources
#include linux_networkinfo.sources
#include macos_networkinfo.sources
../../../external/corefx/src/Common/src/System/Net/Security/CertificateHelper.Unix.cs

View File

@@ -1,3 +1,6 @@
#include mobile_System.dll.sources
#include corefx.windows.sources
System.Net.NetworkInformation/Win32UnixFactoryPal.cs
../../../external/corefx/src/Common/src/Interop/Windows/kernel32/Interop.CloseHandle.cs