Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mcs/class/corlib')
-rwxr-xr-xmcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs184
-rwxr-xr-xmcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs124
-rwxr-xr-xmcs/class/corlib/Mono.Security.Authenticode/ChangeLog5
-rw-r--r--mcs/class/corlib/Mono.Security.Cryptography/ChangeLog5
-rw-r--r--mcs/class/corlib/Mono.Security.Cryptography/RSAManaged.cs8
-rw-r--r--mcs/class/corlib/Mono.Security.X509/ChangeLog4
-rwxr-xr-xmcs/class/corlib/Mono.Security.X509/X509Chain.cs9
-rw-r--r--mcs/class/corlib/System.IO/ChangeLog26
-rwxr-xr-xmcs/class/corlib/System.IO/Stream.cs1
-rw-r--r--mcs/class/corlib/System.IO/StreamWriter.cs43
-rw-r--r--mcs/class/corlib/System.IO/UnexceptionalStreamReader.cs149
-rw-r--r--mcs/class/corlib/System.IO/UnexceptionalStreamWriter.cs128
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs8
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/ChangeLog26
-rwxr-xr-xmcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs18
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs7
-rw-r--r--mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs3
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/ChangeLog6
-rwxr-xr-xmcs/class/corlib/System.Runtime.InteropServices/UnmanagedType.cs1
-rw-r--r--mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog4
-rw-r--r--mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs23
-rw-r--r--mcs/class/corlib/System.Security.Permissions/ChangeLog6
-rw-r--r--mcs/class/corlib/System.Security.Permissions/PrincipalPermission.cs7
-rw-r--r--mcs/class/corlib/System.Threading/ChangeLog5
-rwxr-xr-xmcs/class/corlib/System.Threading/Timer.cs3
-rw-r--r--mcs/class/corlib/System/Activator.cs14
-rwxr-xr-xmcs/class/corlib/System/AppDomain.cs4
-rw-r--r--mcs/class/corlib/System/ChangeLog55
-rw-r--r--mcs/class/corlib/System/Console.cs6
-rw-r--r--mcs/class/corlib/System/Convert.cs29
-rw-r--r--mcs/class/corlib/System/DateTime.cs20
-rw-r--r--mcs/class/corlib/System/Environment.cs2
-rw-r--r--mcs/class/corlib/System/Random.cs2
-rw-r--r--mcs/class/corlib/System/Version.cs7
-rw-r--r--mcs/class/corlib/Test/System/ChangeLog10
-rwxr-xr-xmcs/class/corlib/Test/System/ConvertTest.cs12
-rw-r--r--mcs/class/corlib/Test/System/VersionTest.cs6
-rwxr-xr-xmcs/class/corlib/corlib.dll.sources2
38 files changed, 833 insertions, 139 deletions
diff --git a/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs b/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs
index 9e5923667b5..c2d609ecec2 100755
--- a/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs
+++ b/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeBase.cs
@@ -5,10 +5,6 @@
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
-// (C) 2004 Novell (http://www.novell.com)
-//
-
-//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
@@ -60,63 +56,167 @@ namespace Mono.Security.Authenticode {
public const string spcIndirectDataContext = "1.3.6.1.4.1.311.2.1.4";
- internal byte[] rawData;
+ private byte[] fileblock;
+ private FileStream fs;
+ private int blockNo;
+ private int blockLength;
+ private int peOffset;
+ private int dirSecurityOffset;
+ private int dirSecuritySize;
public AuthenticodeBase ()
{
+ fileblock = new byte [4096];
}
- protected byte[] HashFile (string fileName, string hashName)
+ internal void Open (string filename)
{
- FileStream fs = new FileStream (fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
- byte[] file = new byte [fs.Length];
- fs.Read (file, 0, file.Length);
- fs.Close ();
+ if (fs != null)
+ Close ();
+ fs = new FileStream (filename, FileMode.Open, FileAccess.Read, FileShare.Read);
+ }
- // MZ - DOS header
- if (BitConverterLE.ToUInt16 (file, 0) != 0x5A4D)
- return null;
+ internal void Close ()
+ {
+ if (fs != null) {
+ fs.Close ();
+ fs = null;
+ blockNo = 0;
+ }
+ }
- // find offset of PE header
- int peOffset = BitConverterLE.ToInt32 (file, 60);
- if (peOffset > file.Length)
- return null;
+ internal bool ReadFirstBlock ()
+ {
+ if (fs == null)
+ return false;
+
+ fs.Position = 0;
+ // read first block - it will include (100% sure)
+ // the MZ header and (99.9% sure) the PE header
+ blockLength = fs.Read (fileblock, 0, fileblock.Length);
+ blockNo = 1;
+ if (blockLength < 64)
+ return false; // invalid PE file
+
+ // 1. Validate the MZ header informations
+ // 1.1. Check for magic MZ at start of header
+ if (BitConverterLE.ToUInt16 (fileblock, 0) != 0x5A4D)
+ return false;
+
+ // 1.2. Find the offset of the PE header
+ peOffset = BitConverterLE.ToInt32 (fileblock, 60);
+ if (peOffset > fileblock.Length) {
+ // just in case (0.1%) this can actually happen
+ string msg = String.Format (Locale.GetText (
+ "Header size too big (> {0} bytes)."),
+ fileblock.Length);
+ throw new NotSupportedException (msg);
+ }
+ if (peOffset > fs.Length)
+ return false;
- // PE - NT header
- if (BitConverterLE.ToUInt16 (file, peOffset) != 0x4550)
- return null;
+ // 2. Read between DOS header and first part of PE header
+ // 2.1. Check for magic PE at start of header
+ if (BitConverterLE.ToUInt16 (fileblock, peOffset) != 0x4550)
+ return false;
- // IMAGE_DIRECTORY_ENTRY_SECURITY
- int dirSecurityOffset = BitConverterLE.ToInt32 (file, peOffset + 152);
- int dirSecuritySize = BitConverterLE.ToInt32 (file, peOffset + 156);
+ // 2.2. Locate IMAGE_DIRECTORY_ENTRY_SECURITY (offset and size)
+ dirSecurityOffset = BitConverterLE.ToInt32 (fileblock, peOffset + 152);
+ dirSecuritySize = BitConverterLE.ToInt32 (fileblock, peOffset + 156);
+
+ return true;
+ }
+
+ internal byte[] GetSecurityEntry ()
+ {
+ if (blockNo < 1)
+ ReadFirstBlock ();
if (dirSecuritySize > 8) {
- rawData = new byte [dirSecuritySize - 8];
- Buffer.BlockCopy (file, dirSecurityOffset + 8, rawData, 0, rawData.Length);
-/* DEBUG
- FileStream debug = new FileStream (fileName + ".sig", FileMode.Create, FileAccess.Write);
- debug.Write (rawData, 0, rawData.Length);
- debug.Close ();*/
+ // remove header from size (not ASN.1 based)
+ byte[] secEntry = new byte [dirSecuritySize - 8];
+ // position after header and read entry
+ fs.Position = dirSecurityOffset + 8;
+ fs.Read (secEntry, 0, secEntry.Length);
+ return secEntry;
+ }
+ return null;
+ }
+
+ // returns null if the file isn't signed
+ internal byte[] GetHash (HashAlgorithm hash)
+ {
+ if (blockNo < 1)
+ ReadFirstBlock ();
+ fs.Position = blockLength;
+
+ // hash the rest of the file
+ long n = fs.Length - blockLength;
+ // minus any authenticode signature (with 8 bytes header)
+ if (dirSecurityOffset > 0) {
+ // it is also possible that the signature block
+ // starts within the block in memory (small EXE)
+ if (dirSecurityOffset < blockLength) {
+ blockLength = dirSecurityOffset;
+ n = 0;
+ }
+ else
+ n -= (dirSecuritySize);
}
- else
- rawData = null;
- HashAlgorithm hash = HashAlgorithm.Create (hashName);
- // 0 to 215 (216) then skip 4 (checksum)
+ // Authenticode(r) gymnastics
+ // Hash from (generally) 0 to 215 (216 bytes)
int pe = peOffset + 88;
- hash.TransformBlock (file, 0, pe, file, 0);
+ hash.TransformBlock (fileblock, 0, pe, fileblock, 0);
+ // then skip 4 for checksum
pe += 4;
- // 220 to 279 (60) then skip 8 (IMAGE_DIRECTORY_ENTRY_SECURITY)
- hash.TransformBlock (file, pe, 60, file, pe);
+ // Continue hashing from (generally) 220 to 279 (60 bytes)
+ hash.TransformBlock (fileblock, pe, 60, fileblock, pe);
+ // then skip 8 bytes for IMAGE_DIRECTORY_ENTRY_SECURITY
pe += 68;
- // 288 to end of file
- int n = file.Length - pe;
- // minus any authenticode signature (with 8 bytes header)
- if (dirSecurityOffset != 0)
- n -= (dirSecuritySize);
- hash.TransformFinalBlock (file, pe, n);
+ // everything is present so start the hashing
+ if (n == 0) {
+ // hash the (only) block
+ hash.TransformFinalBlock (fileblock, pe, blockLength - pe);
+ }
+ else {
+ // hash the last part of the first (already in memory) block
+ hash.TransformBlock (fileblock, pe, blockLength - pe, fileblock, 0);
+
+ // hash by blocks of 4096 bytes
+ long blocks = (n >> 12);
+ int remainder = (int)(n - (blocks << 12));
+ if (remainder == 0) {
+ blocks--;
+ remainder = 4096;
+ }
+ // blocks
+ while (blocks-- > 0) {
+ fs.Read (fileblock, 0, fileblock.Length);
+ hash.TransformBlock (fileblock, 0, fileblock.Length, fileblock, 0);
+ }
+ // remainder
+ if (fs.Read (fileblock, 0, remainder) != remainder)
+ return null;
+ hash.TransformFinalBlock (fileblock, 0, remainder);
+ }
return hash.Hash;
}
+
+ // for compatibility only
+ protected byte[] HashFile (string fileName, string hashName)
+ {
+ try {
+ Open (fileName);
+ HashAlgorithm hash = HashAlgorithm.Create (hashName);
+ byte[] result = GetHash (hash);
+ Close ();
+ return result;
+ }
+ catch {
+ return null;
+ }
+ }
}
}
diff --git a/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs b/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs
index 803781954f7..ea0bd30e242 100755
--- a/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs
+++ b/mcs/class/corlib/Mono.Security.Authenticode/AuthenticodeDeformatter.cs
@@ -2,12 +2,9 @@
// AuthenticodeDeformatter.cs: Authenticode signature validator
//
// Author:
-// Sebastien Pouliot (spouliot@motus.com)
+// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
-//
-
-//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
@@ -57,6 +54,9 @@ namespace Mono.Security.Authenticode {
private DateTime timestamp;
private X509Certificate signingCertificate;
private int reason;
+ private bool trustedRoot;
+ private bool trustedTimestampRoot;
+ private byte[] entry;
private X509Chain signerChain;
private X509Chain timestampChain;
@@ -70,17 +70,20 @@ namespace Mono.Security.Authenticode {
public AuthenticodeDeformatter (string fileName) : this ()
{
- if (!CheckSignature (fileName)) {
- // invalid or no signature
- if (signedHash != null)
- throw new COMException ("Invalid signature");
- // no exception is thrown when there's no signature in the PE file
- }
+ FileName = fileName;
}
public string FileName {
get { return filename; }
- set { CheckSignature (value); }
+ set {
+ Reset ();
+ try {
+ CheckSignature (value);
+ }
+ catch {
+ reason = 1;
+ }
+ }
}
public byte[] Hash {
@@ -101,7 +104,7 @@ namespace Mono.Security.Authenticode {
public bool IsTrusted ()
{
- if (rawData == null) {
+ if (entry == null) {
reason = 1;
return false;
}
@@ -111,13 +114,13 @@ namespace Mono.Security.Authenticode {
return false;
}
- if (signerChain.Root == null) {
+ if ((signerChain.Root == null) || !trustedRoot) {
reason = 6;
return false;
}
if (timestamp != DateTime.MinValue) {
- if (timestampChain.Root == null) {
+ if ((timestampChain.Root == null) || !trustedTimestampRoot) {
reason = 6;
return false;
}
@@ -139,7 +142,11 @@ namespace Mono.Security.Authenticode {
}
public byte[] Signature {
- get { return (byte[]) rawData.Clone (); }
+ get {
+ if (entry == null)
+ return null;
+ return (byte[]) entry.Clone ();
+ }
}
public DateTime Timestamp {
@@ -157,43 +164,58 @@ namespace Mono.Security.Authenticode {
private bool CheckSignature (string fileName)
{
filename = fileName;
-
- // by default we try with MD5
- string hashName = "MD5";
- // compare the signature's hash with the hash of the file
- hash = HashFile (filename, hashName);
-
- // is a signature present ?
- if (rawData == null)
+ base.Open (filename);
+ entry = base.GetSecurityEntry ();
+ if (entry == null) {
+ // no signature is present
+ reason = 1;
+ base.Close ();
return false;
+ }
- PKCS7.ContentInfo ci = new PKCS7.ContentInfo (rawData);
- if (ci.ContentType != PKCS7.Oid.signedData)
+ PKCS7.ContentInfo ci = new PKCS7.ContentInfo (entry);
+ if (ci.ContentType != PKCS7.Oid.signedData) {
+ base.Close ();
return false;
+ }
PKCS7.SignedData sd = new PKCS7.SignedData (ci.Content);
- if (sd.ContentInfo.ContentType != spcIndirectDataContext)
+ if (sd.ContentInfo.ContentType != spcIndirectDataContext) {
+ base.Close ();
return false;
+ }
coll = sd.Certificates;
ASN1 spc = sd.ContentInfo.Content;
signedHash = spc [0][1][1];
- if (signedHash.Length == 20) {
- // seems to be SHA-1, restart hashing
- hashName = "SHA1";
- hash = HashFile (filename, hashName);
+
+ HashAlgorithm ha = null;
+ switch (signedHash.Length) {
+ case 16:
+ ha = HashAlgorithm.Create ("MD5");
+ hash = GetHash (ha);
+ break;
+ case 20:
+ ha = HashAlgorithm.Create ("SHA1");
+ hash = GetHash (ha);
+ break;
+ default:
+ reason = 5;
+ base.Close ();
+ return false;
}
+ base.Close ();
if (!signedHash.CompareValue (hash))
return false;
// messageDigest is a hash of spcIndirectDataContext (which includes the file hash)
byte[] spcIDC = spc [0].Value;
- HashAlgorithm ha = HashAlgorithm.Create (hashName);
+ ha.Initialize (); // re-using hash instance
byte[] messageDigest = ha.ComputeHash (spcIDC);
- return VerifySignature (sd, messageDigest, hashName);
+ return VerifySignature (sd, messageDigest, ha);
}
private bool CompareIssuerSerial (string issuer, byte[] serial, X509Certificate x509)
@@ -213,7 +235,7 @@ namespace Mono.Security.Authenticode {
}
//private bool VerifySignature (ASN1 cs, byte[] calculatedMessageDigest, string hashName)
- private bool VerifySignature (PKCS7.SignedData sd, byte[] calculatedMessageDigest, string hashName)
+ private bool VerifySignature (PKCS7.SignedData sd, byte[] calculatedMessageDigest, HashAlgorithm ha)
{
string contentType = null;
ASN1 messageDigest = null;
@@ -242,7 +264,7 @@ namespace Mono.Security.Authenticode {
case "1.3.6.1.4.1.311.2.1.12":
// spcSpOpusInfo (Microsoft code signing)
try {
- spcSpOpusInfo = System.Text.Encoding.UTF8.GetString (attr[1][0][1][0].Value);
+ spcSpOpusInfo = System.Text.Encoding.UTF8.GetString (attr[1][0][0][0].Value);
}
catch (NullReferenceException) {
spcSpOpusInfo = null;
@@ -262,13 +284,13 @@ namespace Mono.Security.Authenticode {
return false;
// verify signature
- string hashOID = CryptoConfig.MapNameToOID (hashName);
+ string hashOID = CryptoConfig.MapNameToOID (ha.ToString ());
// change to SET OF (not [0]) as per PKCS #7 1.5
ASN1 aa = new ASN1 (0x31);
foreach (ASN1 a in sd.SignerInfo.AuthenticatedAttributes)
aa.Add (a);
- HashAlgorithm ha = HashAlgorithm.Create (hashName);
+ ha.Initialize ();
byte[] p7hash = ha.ComputeHash (aa.GetBytes ());
byte[] signature = sd.SignerInfo.Signature;
@@ -282,10 +304,9 @@ namespace Mono.Security.Authenticode {
RSACryptoServiceProvider rsa = (RSACryptoServiceProvider) x509.RSA;
if (rsa.VerifyHash (p7hash, hashOID, signature)) {
signerChain.LoadCertificates (coll);
- if (signerChain.Build (x509))
- signingCertificate = x509;
- else
- return false;
+ trustedRoot = signerChain.Build (x509);
+ signingCertificate = x509;
+ break;
}
}
}
@@ -301,17 +322,18 @@ namespace Mono.Security.Authenticode {
// countersignature (1 2 840 113549 1 9 6)
// SET {
PKCS7.SignerInfo cs = new PKCS7.SignerInfo (attr [1]);
- return VerifyCounterSignature (cs, signature, hashName);
+ trustedTimestampRoot = VerifyCounterSignature (cs, signature);
+ break;
default:
// we don't support other unauthenticated attributes
break;
}
}
- return true;
+ return (trustedRoot && trustedTimestampRoot);
}
- private bool VerifyCounterSignature (PKCS7.SignerInfo cs, byte[] signature, string hashName)
+ private bool VerifyCounterSignature (PKCS7.SignerInfo cs, byte[] signature)
{
// SEQUENCE {
// INTEGER 1
@@ -358,6 +380,7 @@ namespace Mono.Security.Authenticode {
if (messageDigest == null)
return false;
// TODO: must be read from the ASN.1 structure
+ string hashName = null;
switch (messageDigest.Length) {
case 16:
hashName = "MD5";
@@ -398,5 +421,20 @@ namespace Mono.Security.Authenticode {
// no certificate can verify this signature!
return false;
}
+
+ private void Reset ()
+ {
+ filename = null;
+ entry = null;
+ hash = null;
+ signedHash = null;
+ signingCertificate = null;
+ reason = -1;
+ trustedRoot = false;
+ trustedTimestampRoot = false;
+ signerChain.Reset ();
+ timestampChain.Reset ();
+ timestamp = DateTime.MinValue;
+ }
}
}
diff --git a/mcs/class/corlib/Mono.Security.Authenticode/ChangeLog b/mcs/class/corlib/Mono.Security.Authenticode/ChangeLog
index 7f9398815f2..da0e586a096 100755
--- a/mcs/class/corlib/Mono.Security.Authenticode/ChangeLog
+++ b/mcs/class/corlib/Mono.Security.Authenticode/ChangeLog
@@ -1,3 +1,8 @@
+2004-09-07 Sebastien Pouliot <sebastien@ximian.com>
+
+ * AuthenticodeBase.cs: Merge optimizations from HEAD.
+ * AuthenticodeDeformatter.cs: Merge optimizations from HEAD.
+
2004-04-28 Sebastien Pouliot <sebastien@ximian.com>
* AuthenticodeBase.cs: In sync with Mono.Security.dll version.
diff --git a/mcs/class/corlib/Mono.Security.Cryptography/ChangeLog b/mcs/class/corlib/Mono.Security.Cryptography/ChangeLog
index 4162be45b05..1515435dce9 100644
--- a/mcs/class/corlib/Mono.Security.Cryptography/ChangeLog
+++ b/mcs/class/corlib/Mono.Security.Cryptography/ChangeLog
@@ -1,3 +1,8 @@
+2004-09-29 Sebastien Pouliot <sebastien@ximian.com>
+
+ * RSAManaged.cs: KeySize is now always a multiple of 8 bits.
+ Fix #66929.
+
2004-06-23 Sebastien Pouliot <sebastien@ximian.com>
* SymmetricTransform.cs: Reduce by one the number of block when
diff --git a/mcs/class/corlib/Mono.Security.Cryptography/RSAManaged.cs b/mcs/class/corlib/Mono.Security.Cryptography/RSAManaged.cs
index 40f58801dce..82b16f6b291 100644
--- a/mcs/class/corlib/Mono.Security.Cryptography/RSAManaged.cs
+++ b/mcs/class/corlib/Mono.Security.Cryptography/RSAManaged.cs
@@ -149,8 +149,12 @@ namespace Mono.Security.Cryptography {
public override int KeySize {
get {
// in case keypair hasn't been (yet) generated
- if (keypairGenerated)
- return n.BitCount ();
+ if (keypairGenerated) {
+ int ks = n.BitCount ();
+ if ((ks & 7) != 0)
+ ks = ks + (8 - (ks & 7));
+ return ks;
+ }
else
return base.KeySize;
}
diff --git a/mcs/class/corlib/Mono.Security.X509/ChangeLog b/mcs/class/corlib/Mono.Security.X509/ChangeLog
index 5cfdfbd7a78..add41ab01a7 100644
--- a/mcs/class/corlib/Mono.Security.X509/ChangeLog
+++ b/mcs/class/corlib/Mono.Security.X509/ChangeLog
@@ -1,3 +1,7 @@
+2004-09-07 Sebastien Pouliot <sebastien@ximian.com>
+
+ * X509Chain.cs: Merge bug fixes from HEAD.
+
2004-05-27 Sebastien Pouliot <sebastien@ximian.com>
* X509Certificate.cs: Rethrow original exception when parsing X.509
diff --git a/mcs/class/corlib/Mono.Security.X509/X509Chain.cs b/mcs/class/corlib/Mono.Security.X509/X509Chain.cs
index 0ff5d875ac5..f8035e6c661 100755
--- a/mcs/class/corlib/Mono.Security.X509/X509Chain.cs
+++ b/mcs/class/corlib/Mono.Security.X509/X509Chain.cs
@@ -9,10 +9,6 @@
// Sebastien Pouliot <sebastien@ximian.com>
//
// (C) 2003 Motus Technologies Inc. (http://www.motus.com)
-// (C) 2004 Novell (http://www.novell.com)
-//
-
-//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
@@ -136,7 +132,7 @@ namespace Mono.Security.X509 {
tmp = FindCertificateParent (x);
if (x != null) {
_chain.Add (x);
- tmp = x; // last valid
+ x = tmp; // last valid
}
}
// find a trusted root
@@ -193,7 +189,8 @@ namespace Mono.Security.X509 {
_status = X509ChainStatusFlags.NoError;
roots = null; // this force a reload
certs.Clear ();
- _chain.Clear ();
+ if (_chain != null)
+ _chain.Clear ();
}
// private stuff
diff --git a/mcs/class/corlib/System.IO/ChangeLog b/mcs/class/corlib/System.IO/ChangeLog
index 2c281d7651c..2a98da3be31 100644
--- a/mcs/class/corlib/System.IO/ChangeLog
+++ b/mcs/class/corlib/System.IO/ChangeLog
@@ -1,3 +1,29 @@
+2004-09-19 Dick Porter <dick@ximian.com>
+
+ * UnexceptionalStreamWriter.cs:
+ * UnexceptionalStreamReader.cs: Wrappers around StreamWriter and
+ StreamReader that catch IOException. Used by System.Console so
+ that graphical applications dont get IO errors when their
+ stdin/out/err vanishes (ie when they spew debug output.)
+
+2004-09-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Stream.cs: Close() does not call Flush(). Fixes bug #65340.
+
+2004-08-26 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * StreamWriter.cs: avoid String.ToCharArray for perf.
+
+2004-08-18 Dick Porter <dick@ximian.com>
+
+ * StreamWriter.cs: Flush the buffer if AutoFlush is set to true.
+ Fixes bug 63063, patch by Laurent Debacker (debackerl@yahoo.com).
+
+2004-08-13 Dick Porter <dick@ximian.com>
+
+ * StreamWriter.cs: Allow FileShare.Read access to the underlying
+ FileStream, to be compatible with MS. Fixes bug 62152.
+
2004-07-06 Dick Porter <dick@ximian.com>
* MonoIO.cs: Add ERROR_INVALID_PARAMETER to the exception list.
diff --git a/mcs/class/corlib/System.IO/Stream.cs b/mcs/class/corlib/System.IO/Stream.cs
index 04884fb5e3d..6623da319a1 100755
--- a/mcs/class/corlib/System.IO/Stream.cs
+++ b/mcs/class/corlib/System.IO/Stream.cs
@@ -77,7 +77,6 @@ namespace System.IO
public virtual void Close ()
{
- Flush ();
}
void IDisposable.Dispose ()
diff --git a/mcs/class/corlib/System.IO/StreamWriter.cs b/mcs/class/corlib/System.IO/StreamWriter.cs
index 4c51d0269be..1799d74e6e6 100644
--- a/mcs/class/corlib/System.IO/StreamWriter.cs
+++ b/mcs/class/corlib/System.IO/StreamWriter.cs
@@ -123,7 +123,7 @@ namespace System.IO {
else
mode = FileMode.Create;
- internalStream = new FileStream (path, mode, FileAccess.Write);
+ internalStream = new FileStream (path, mode, FileAccess.Write, FileShare.Read);
if (append)
internalStream.Position = internalStream.Length;
@@ -137,12 +137,16 @@ namespace System.IO {
get {
return iflush;
}
- set {
- if (DisposedAlready)
- throw new ObjectDisposedException("StreamWriter");
- iflush = value;
- }
- }
+ set {
+ if (DisposedAlready)
+ throw new ObjectDisposedException("StreamWriter");
+ iflush = value;
+
+ if (iflush) {
+ Flush ();
+ }
+ }
+ }
public virtual Stream BaseStream {
get {
@@ -245,6 +249,28 @@ namespace System.IO {
index += todo;
decode_pos += todo;
}
+ }
+
+ void LowLevelWrite (string s)
+ {
+ int count = s.Length;
+ int index = 0;
+ while (count > 0) {
+ int todo = decode_buf.Length - decode_pos;
+ if (todo == 0) {
+ Decode ();
+ todo = decode_buf.Length;
+ }
+ if (todo > count)
+ todo = count;
+
+ for (int i = 0; i < todo; i ++)
+ decode_buf [i + decode_pos] = s [i + index];
+
+ count -= todo;
+ index += todo;
+ decode_pos += todo;
+ }
}
public override void Write (char value)
@@ -278,7 +304,8 @@ namespace System.IO {
throw new ObjectDisposedException("StreamWriter");
if (value != null)
- LowLevelWrite (value.ToCharArray (), 0, value.Length);
+ LowLevelWrite (value);
+
if (iflush)
Flush ();
}
diff --git a/mcs/class/corlib/System.IO/UnexceptionalStreamReader.cs b/mcs/class/corlib/System.IO/UnexceptionalStreamReader.cs
new file mode 100644
index 00000000000..7c527459204
--- /dev/null
+++ b/mcs/class/corlib/System.IO/UnexceptionalStreamReader.cs
@@ -0,0 +1,149 @@
+//
+// System.IO.UnexceptionalStreamReader.cs
+//
+// Authors:
+// Dietmar Maurer (dietmar@ximian.com)
+// Miguel de Icaza (miguel@ximian.com)
+// Dick Porter (dick@ximian.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+// Copyright (C) 2004 Novell (http://www.novell.com)
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.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.
+//
+
+
+// This is a wrapper around StreamReader used by System.Console that
+// catches IOException so that graphical applications don't suddenly
+// get IO errors when their terminal vanishes. See
+// UnexceptionalStreamWriter too.
+
+using System;
+using System.Text;
+using System.Runtime.InteropServices;
+
+namespace System.IO {
+ internal class UnexceptionalStreamReader : StreamReader {
+ public UnexceptionalStreamReader(Stream stream)
+ : base (stream)
+ {
+ }
+
+ public UnexceptionalStreamReader(Stream stream, bool detect_encoding_from_bytemarks)
+ : base (stream, detect_encoding_from_bytemarks)
+ {
+ }
+
+ public UnexceptionalStreamReader(Stream stream, Encoding encoding)
+ : base (stream, encoding)
+ {
+ }
+
+ public UnexceptionalStreamReader(Stream stream, Encoding encoding, bool detect_encoding_from_bytemarks)
+ : base (stream, encoding, detect_encoding_from_bytemarks)
+ {
+ }
+
+ public UnexceptionalStreamReader(Stream stream, Encoding encoding, bool detect_encoding_from_bytemarks, int buffer_size)
+ : base (stream, encoding, detect_encoding_from_bytemarks, buffer_size)
+ {
+ }
+
+ public UnexceptionalStreamReader(string path)
+ : base (path)
+ {
+ }
+
+ public UnexceptionalStreamReader(string path, bool detect_encoding_from_bytemarks)
+ : base (path, detect_encoding_from_bytemarks)
+ {
+ }
+
+ public UnexceptionalStreamReader(string path, Encoding encoding)
+ : base (path, encoding)
+ {
+ }
+
+ public UnexceptionalStreamReader(string path, Encoding encoding, bool detect_encoding_from_bytemarks)
+ : base (path, encoding, detect_encoding_from_bytemarks)
+ {
+ }
+
+ public UnexceptionalStreamReader(string path, Encoding encoding, bool detect_encoding_from_bytemarks, int buffer_size)
+ : base (path, encoding, detect_encoding_from_bytemarks, buffer_size)
+ {
+ }
+
+ public override int Peek ()
+ {
+ try {
+ return(base.Peek ());
+ } catch (IOException) {
+ }
+
+ return(-1);
+ }
+
+ public override int Read ()
+ {
+ try {
+ return(base.Read ());
+ } catch (IOException) {
+ }
+
+ return(-1);
+ }
+
+ public override int Read ([In, Out] char[] dest_buffer,
+ int index, int count)
+ {
+ try {
+ return(base.Read (dest_buffer, index, count));
+ } catch (IOException) {
+ }
+
+ return(0);
+ }
+
+ public override string ReadLine()
+ {
+ try {
+ return(base.ReadLine ());
+ } catch (IOException) {
+ }
+
+ return(null);
+ }
+
+ public override string ReadToEnd()
+ {
+ try {
+ return(base.ReadToEnd ());
+ } catch (IOException) {
+ }
+
+ return(null);
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.IO/UnexceptionalStreamWriter.cs b/mcs/class/corlib/System.IO/UnexceptionalStreamWriter.cs
new file mode 100644
index 00000000000..db9fd5842e7
--- /dev/null
+++ b/mcs/class/corlib/System.IO/UnexceptionalStreamWriter.cs
@@ -0,0 +1,128 @@
+//
+// System.IO.StreamWriter.cs
+//
+// Authors:
+// Dietmar Maurer (dietmar@ximian.com)
+// Paolo Molaro (lupus@ximian.com)
+// Dick Porter (dick@ximian.com)
+//
+// (C) Ximian, Inc. http://www.ximian.com
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.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.
+//
+
+
+// This is a wrapper around StreamWriter used by System.Console that
+// catches IOException so that graphical applications don't suddenly
+// get IO errors when their terminal vanishes (ie when they spew debug
+// output.) See UnexceptionalStreamReader too.
+
+using System.Text;
+using System;
+
+namespace System.IO {
+ internal class UnexceptionalStreamWriter: StreamWriter {
+ public UnexceptionalStreamWriter (Stream stream)
+ : base (stream)
+ {
+ }
+
+ public UnexceptionalStreamWriter (Stream stream,
+ Encoding encoding)
+ : base (stream, encoding)
+ {
+ }
+
+ public UnexceptionalStreamWriter (Stream stream,
+ Encoding encoding,
+ int bufferSize)
+ : base (stream, encoding, bufferSize)
+ {
+ }
+
+ public UnexceptionalStreamWriter (string path)
+ : base (path)
+ {
+ }
+
+ public UnexceptionalStreamWriter (string path, bool append)
+ : base (path, append)
+ {
+ }
+
+ public UnexceptionalStreamWriter (string path, bool append,
+ Encoding encoding)
+ : base (path, append, encoding)
+ {
+ }
+
+ public UnexceptionalStreamWriter (string path, bool append,
+ Encoding encoding,
+ int bufferSize)
+ : base (path, append, encoding, bufferSize)
+ {
+ }
+
+ public override void Flush ()
+ {
+ try {
+ base.Flush ();
+ } catch (IOException) {
+ }
+ }
+
+ public override void Write (char[] buffer, int index,
+ int count)
+ {
+ try {
+ base.Write (buffer, index, count);
+ } catch (IOException) {
+ }
+ }
+
+ public override void Write (char value)
+ {
+ try {
+ base.Write (value);
+ } catch (IOException) {
+ }
+ }
+
+ public override void Write (char[] value)
+ {
+ try {
+ base.Write (value);
+ } catch (IOException) {
+ }
+ }
+
+ public override void Write (string value)
+ {
+ try {
+ base.Write (value);
+ } catch (IOException) {
+ }
+ }
+ }
+}
diff --git a/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
index ebe86410469..344395be1a3 100755
--- a/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/AssemblyBuilder.cs
@@ -131,8 +131,16 @@ namespace System.Reflection.Emit {
}
if (n.KeyPair != null) {
+ // full keypair is available (for signing)
sn = n.KeyPair.StrongName ();
}
+ else {
+ // public key is available (for delay-signing)
+ byte[] pk = n.GetPublicKey ();
+ if ((pk != null) && (pk.Length > 0)) {
+ sn = new Mono.Security.StrongName (pk);
+ }
+ }
basic_init (this);
}
diff --git a/mcs/class/corlib/System.Reflection.Emit/ChangeLog b/mcs/class/corlib/System.Reflection.Emit/ChangeLog
index 4a3fa12c3b0..0ecc28b55ff 100644
--- a/mcs/class/corlib/System.Reflection.Emit/ChangeLog
+++ b/mcs/class/corlib/System.Reflection.Emit/ChangeLog
@@ -1,3 +1,29 @@
+2004-10-06 Zoltan Varga <vargaz@freemail.hu>
+
+ * ModuleBuilder.cs (GetTypes): Fix length of returned array. Fixes
+ #65931.
+
+2004-10-04 Zoltan Varga <vargaz@freemail.hu>
+
+ * ModuleBuilder.cs (DefineType): Check for duplicate type names. Fixes
+ #65988.
+
+2004-09-17 Zoltan Varga <vargaz@freemail.hu>
+
+ * CustomAttributeBuilder.cs: Applied patch from Marcus Urban (mathpup@mylinuxisp.com). Add support for defining custom marshallers by calling SetCustomAttribute.
+
+2004-09-09 Zoltan Varga <vargaz@freemail.hu>
+
+ * TypeBuilder.cs: Set the table_idx of the global type to 1.
+
+ * ModuleBuilder.cs: Save the main module of the assembly even if it is
+ transient.
+
+2004-08-13 Sebastien Pouliot <sebastien@ximian.com>
+
+ * AssemblyBuilder.cs: (Partly) Fix delay-signing issue (#56621) when
+ MCS is used on the MS runtime (other part of the fix is for MCS).
+
2004-07-24 Martin Baulig <martin@ximian.com>
* TypeBuilder.cs (TypeBuilder.UnspecifiedTypeSize): Set this to 0
diff --git a/mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs
index e85e67022bc..daadb065ed3 100755
--- a/mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs
@@ -198,6 +198,8 @@ namespace System.Reflection.Emit {
int sizeConst = 0;
int value;
int utype; /* the (stupid) ctor takes a short or an enum ... */
+ Type marshalTypeRef = null;
+ string marshalCookie = String.Empty;
utype = (int)data [2];
utype |= ((int)data [3]) << 8;
@@ -231,7 +233,21 @@ namespace System.Reflection.Emit {
value |= ((int)data [pos++]) << 24;
sizeConst = value;
break;
+ case "MarshalTypeRef":
+ case "MarshalType":
+ len = decode_len (data, pos, out pos);
+ marshalTypeRef = Type.GetType (string_from_bytes (data, pos, len));
+ pos += len;
+ break;
+ case "MarshalCookie":
+ len = decode_len (data, pos, out pos);
+ marshalCookie = string_from_bytes (data, pos, len);
+ pos += len;
+ break;
default:
+ len = decode_len(data, pos, out pos);
+ string v = string_from_bytes (data, pos, len);
+ pos += len;
break;
}
}
@@ -245,6 +261,8 @@ namespace System.Reflection.Emit {
return UnmanagedMarshal.DefineByValArray (sizeConst);
case UnmanagedType.ByValTStr:
return UnmanagedMarshal.DefineByValTStr (sizeConst);
+ case UnmanagedType.CustomMarshaler:
+ return UnmanagedMarshal.DefineCustom ( marshalTypeRef, marshalCookie, marshalTypeRef.ToString (), Guid.Empty);
default:
return UnmanagedMarshal.DefineUnmanagedMarshal ((UnmanagedType)utype);
}
diff --git a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
index a7d4888d6d7..eabb8f84fb9 100644
--- a/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/ModuleBuilder.cs
@@ -252,6 +252,8 @@ namespace System.Reflection.Emit {
}
private TypeBuilder DefineType (string name, TypeAttributes attr, Type parent, Type[] interfaces, PackingSize packsize, int typesize) {
+ if (name_cache.Contains (name))
+ throw new ArgumentException ("Duplicate type name within an assembly.");
TypeBuilder res = new TypeBuilder (this, name, attr, parent, interfaces, packsize, typesize, null);
if (types != null) {
if (types.Length == num_types) {
@@ -433,7 +435,7 @@ namespace System.Reflection.Emit {
if (types == null)
return new TypeBuilder [0];
- int n = types.Length;
+ int n = num_types;
TypeBuilder [] copy = new TypeBuilder [n];
Array.Copy (types, copy, n);
@@ -624,9 +626,8 @@ namespace System.Reflection.Emit {
internal void Save ()
{
- if (transient)
+ if (transient && !is_main)
return;
-
if ((global_type != null) && (global_type_created == null))
global_type_created = global_type.CreateType ();
diff --git a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
index c0059b54286..edcf429d9cc 100644
--- a/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
+++ b/mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
@@ -97,6 +97,7 @@ namespace System.Reflection.Emit {
this.attrs = attr;
this.class_size = 0;
fullname = this.tname = "<Module>";
+ this.table_idx = 1;
this.nspace = "";
pmodule = mb;
setup_internal_class (this);
@@ -987,7 +988,7 @@ namespace System.Reflection.Emit {
public override Type[] GetNestedTypes (BindingFlags bindingAttr) {
bool match;
ArrayList result = new ArrayList ();
-
+
if (subtypes == null)
return Type.EmptyTypes;
foreach (TypeBuilder t in subtypes) {
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog b/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog
index 3eab4fba987..b74738d5faf 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog
+++ b/mcs/class/corlib/System.Runtime.InteropServices/ChangeLog
@@ -1,3 +1,9 @@
+2004-09-10 Raja R Harinath <rharinath@novell.com>
+
+ Fix bootstrap with mcs 1.1.x.
+ * UnmanagedType.cs (UnmanagedType.__mono_bootstrap_NativeTypeMax):
+ Mark as non-compliant to CLS.
+
2004-06-22 Raja R Harinath <rharinath@novell.com>
Fix bootstrap with mcs 0.31.
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/UnmanagedType.cs b/mcs/class/corlib/System.Runtime.InteropServices/UnmanagedType.cs
index 6502e1f90f6..1b5f3363c24 100755
--- a/mcs/class/corlib/System.Runtime.InteropServices/UnmanagedType.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/UnmanagedType.cs
@@ -188,6 +188,7 @@ namespace System.Runtime.InteropServices {
#if BOOTSTRAP_WITH_OLDLIB
/// <summary>
/// </summary>
+ [CLSCompliant(false)]
__mono_bootstrap_NativeTypeMax = 80,
#endif
} // UnmanagedType
diff --git a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog
index b5a036af423..86be09eef0a 100644
--- a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog
+++ b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/ChangeLog
@@ -1,3 +1,7 @@
+2004-09-07 Sebastien Pouliot <sebastien@ximian.com>
+
+ * X509Certificate.cs: Merge changes from HEAD.
+
2003-12-15 Sebastien Pouliot <spouliot@videotron.ca>
* X509Certificate.cs: Removed old (commented) Authenticode stuff.
diff --git a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
index af5722f601d..5d3f9dd8177 100644
--- a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
+++ b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs
@@ -116,15 +116,26 @@ namespace System.Security.Cryptography.X509Certificates {
[MonoTODO ("Incomplete - minimal validation in this version")]
public static X509Certificate CreateFromSignedFile (string filename)
{
- AuthenticodeDeformatter a = new AuthenticodeDeformatter (filename);
- if (a.SigningCertificate != null) {
- return new X509Certificate (a.SigningCertificate.RawData);
- }
- else {
+ try {
+ AuthenticodeDeformatter a = new AuthenticodeDeformatter (filename);
+ if (a.SigningCertificate != null) {
+ if (a.Reason != 0) {
+ string msg = String.Format (Locale.GetText (
+ "Invalid digital signature on {0}, reason #{1}."),
+ filename, a.Reason);
+ throw new COMException (msg);
+ }
+ return new X509Certificate (a.SigningCertificate.RawData);
+ }
+
// if no signature is present return an empty certificate
byte[] cert = null; // must not confuse compiler about null ;)
return new X509Certificate (cert);
}
+ catch (Exception e) {
+ string msg = String.Format (Locale.GetText ("Couldn't extract digital signature from {0}."), filename);
+ throw new COMException (msg, e);
+ }
}
// constructors
@@ -410,4 +421,4 @@ namespace System.Security.Cryptography.X509Certificates {
}
#endif
}
-} \ No newline at end of file
+}
diff --git a/mcs/class/corlib/System.Security.Permissions/ChangeLog b/mcs/class/corlib/System.Security.Permissions/ChangeLog
index 219a8c199ea..63e95738285 100644
--- a/mcs/class/corlib/System.Security.Permissions/ChangeLog
+++ b/mcs/class/corlib/System.Security.Permissions/ChangeLog
@@ -1,3 +1,9 @@
+2004-10-05 Sebastien Pouliot <sebastien@ximian.com>
+
+ * PrincipalPermission.cs: Fixed bug where a change to a permission
+ (e.g. Copy, Union) could affect multiple instances. Fixed FromXml
+ to clear existing entries.
+
2004-06-10 Gert Driesen <drieseng@users.sourceforge.net>
* StrongNameIdentityPermission.cs: removed extra useless finalizer
diff --git a/mcs/class/corlib/System.Security.Permissions/PrincipalPermission.cs b/mcs/class/corlib/System.Security.Permissions/PrincipalPermission.cs
index d1f23c091a5..17235490015 100644
--- a/mcs/class/corlib/System.Security.Permissions/PrincipalPermission.cs
+++ b/mcs/class/corlib/System.Security.Permissions/PrincipalPermission.cs
@@ -98,7 +98,7 @@ namespace System.Security.Permissions {
internal PrincipalPermission (ArrayList principals)
{
- this.principals = principals;
+ this.principals = (ArrayList) principals.Clone ();
}
// Properties
@@ -147,6 +147,7 @@ namespace System.Security.Permissions {
if ((esd.Attributes ["version"] as string) != "1")
throw new ArgumentException ("wrong version");
+ principals.Clear ();
// Children is null, not empty, when no child is present
if (esd.Children != null) {
foreach (SecurityElement se in esd.Children) {
@@ -273,7 +274,7 @@ namespace System.Security.Permissions {
PrincipalPermission union = new PrincipalPermission (principals);
foreach (PrincipalInfo pi in o.principals)
- principals.Add (pi);
+ union.principals.Add (pi);
return union;
}
@@ -284,4 +285,4 @@ namespace System.Security.Permissions {
return 8;
}
}
-} \ No newline at end of file
+}
diff --git a/mcs/class/corlib/System.Threading/ChangeLog b/mcs/class/corlib/System.Threading/ChangeLog
index d6236617956..d441965fb9b 100644
--- a/mcs/class/corlib/System.Threading/ChangeLog
+++ b/mcs/class/corlib/System.Threading/ChangeLog
@@ -1,3 +1,8 @@
+2004-09-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Timer.cs: don't invoke the callback twice when the timer changes.
+ Fixes bug #66116.
+
2004-08-04 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* Timer.cs: don't invoke the callback if the period changes before the
diff --git a/mcs/class/corlib/System.Threading/Timer.cs b/mcs/class/corlib/System.Threading/Timer.cs
index 1675a5a4be7..1bba6fa581e 100755
--- a/mcs/class/corlib/System.Threading/Timer.cs
+++ b/mcs/class/corlib/System.Threading/Timer.cs
@@ -128,6 +128,9 @@ namespace System.Threading
wait.Reset ();
signaled = wait.WaitOne (period, false);
+ if (aborted)
+ break;
+
if (!signaled) {
callback (state);
} else if (!WaitForDueTime ()) {
diff --git a/mcs/class/corlib/System/Activator.cs b/mcs/class/corlib/System/Activator.cs
index 4727251d9e6..6cb4c24b262 100644
--- a/mcs/class/corlib/System/Activator.cs
+++ b/mcs/class/corlib/System/Activator.cs
@@ -168,9 +168,10 @@ namespace System
length = args.Length;
Type [] atypes = new Type [length];
- for (int i = 0; i < length; ++i) {
- atypes [i] = args [i].GetType ();
- }
+ for (int i = 0; i < length; ++i)
+ if (args [i] != null)
+ atypes [i] = args [i].GetType ();
+
ConstructorInfo ctor = type.GetConstructor (atypes);
if (ctor == null) {
if (type.IsValueType && atypes.Length == 0)
@@ -213,9 +214,10 @@ namespace System
length = args.Length;
Type[] atypes = new Type [length];
- for (int i = 0; i < length; ++i) {
- atypes [i] = args [i].GetType ();
- }
+ for (int i = 0; i < length; ++i)
+ if (args [i] != null)
+ atypes [i] = args [i].GetType ();
+
ConstructorInfo ctor = type.GetConstructor (bindingAttr, binder, atypes, null);
if (ctor == null) {
// Not sure about this
diff --git a/mcs/class/corlib/System/AppDomain.cs b/mcs/class/corlib/System/AppDomain.cs
index 06ab7351c93..e987f1a7b4f 100755
--- a/mcs/class/corlib/System/AppDomain.cs
+++ b/mcs/class/corlib/System/AppDomain.cs
@@ -63,10 +63,10 @@ namespace System
static string _process_guid;
[ThreadStatic]
- Hashtable type_resolve_in_progress;
+ static Hashtable type_resolve_in_progress;
[ThreadStatic]
- Hashtable assembly_resolve_in_progress;
+ static Hashtable assembly_resolve_in_progress;
// Evidence evidence;
diff --git a/mcs/class/corlib/System/ChangeLog b/mcs/class/corlib/System/ChangeLog
index 8e4560b1bea..f9b59c29d4f 100644
--- a/mcs/class/corlib/System/ChangeLog
+++ b/mcs/class/corlib/System/ChangeLog
@@ -1,3 +1,58 @@
+2004-10-08 Zoltan Varga <vargaz@freemail.hu>
+
+ * Convert.cs (ToType): Throw an exception when converting null to a
+ valuetype. Fixes #67780.
+
+2004-10-08 Atsushi Enomoto <atsushi@ximian.com>
+
+ * DateTime.cs : Removed incorrectly injected HEAD fix.
+
+2004-10-08 Atsushi Enomoto <atsushi@ximian.com>
+
+ * DateTime.cs : When it it not exact parse, 'Z' is allowed as a suffix
+ of m/s/t/z. This fixes bug 66723.
+
+2004-10-04 Zoltan Varga <vargaz@freemail.hu>
+
+ * AppDomain.cs: Make ThreadStatic variables static. Fixes #56614.
+
+2004-09-30 Geoff Norton <gnorton@customerdna.com>
+
+ * Convert.cs: ConvertToBase* was not endian aware. Implemented EndianSwap
+ and swapping of all values before going into the BitConverter so that values
+ are returned with proper endianess.
+
+2004-09-23 Martin Garton <martin@wrasse.demon.co.uk>
+
+ * Convert.cs: ToType was returning unconverted object when it should
+ fail with an ArgumentException.
+
+2004-09-19 Dick Porter <dick@ximian.com>
+
+ * Console.cs: Use the internal wrappers for StreamReader and
+ StreamWriter that catch IOException.
+
+2004-08-29 Ben Maurer <bmaurer@users.sourceforge.net>
+
+ * Activator.cs (CreateInstance): If an argument is null,
+ do not call GetType () on it. #63852
+
+2004-09-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * Environment.cs: (ExpandEnvironmentVariables) don't nullify the case
+ insensitive environment variables hashtable once we create it.
+
+2004-08-19 Atsushi Enomoto <atsushi@ximian.com>
+
+ * DateTime.cs : When hour format is "hh", MS.NET (maybe incorrectly)
+ allows 12, that should not be accepted (13 is rejected) and
+ interpreted as 0. This fixes bug 63376.
+
+2004-08-17 Sebastien Pouliot <sebastien@ximian.com>
+
+ * Version.cs: Fixed Clone so we can use it on versions with only
+ major/minor or major/minor/build.
+
2004-07-07 Geoff Norton <gnorton@customerdna.com>
* Monotype.cs: Patch for bug #58844. Dont throw exceptions right away;
diff --git a/mcs/class/corlib/System/Console.cs b/mcs/class/corlib/System/Console.cs
index 8a0830a7328..f71b4069c43 100644
--- a/mcs/class/corlib/System/Console.cs
+++ b/mcs/class/corlib/System/Console.cs
@@ -63,15 +63,15 @@ namespace System
encoding = Encoding.Default;
}
- stderr = new StreamWriter (OpenStandardError (0), encoding);
+ stderr = new UnexceptionalStreamWriter (OpenStandardError (0), encoding);
((StreamWriter)stderr).AutoFlush = true;
stderr = TextWriter.Synchronized (stderr, true);
- stdout = new StreamWriter (OpenStandardOutput (0), encoding);
+ stdout = new UnexceptionalStreamWriter (OpenStandardOutput (0), encoding);
((StreamWriter)stdout).AutoFlush = true;
stdout = TextWriter.Synchronized (stdout, true);
- stdin = new StreamReader (OpenStandardInput (0), encoding);
+ stdin = new UnexceptionalStreamReader (OpenStandardInput (0), encoding);
stdin = TextReader.Synchronized (stdin);
}
diff --git a/mcs/class/corlib/System/Convert.cs b/mcs/class/corlib/System/Convert.cs
index f63481831c5..5e15d578704 100644
--- a/mcs/class/corlib/System/Convert.cs
+++ b/mcs/class/corlib/System/Convert.cs
@@ -2559,8 +2559,18 @@ namespace System {
return (long) result;
}
+ private static void EndianSwap (ref byte[] value)
+ {
+ byte[] buf = new byte[value.Length];
+ for (int i = 0; i < value.Length; i++)
+ buf[i] = value[value.Length-1-i];
+ value = buf;
+ }
+
private static string ConvertToBase2 (byte[] value)
{
+ if (!BitConverter.IsLittleEndian)
+ EndianSwap (ref value);
StringBuilder sb = new StringBuilder ();
for (int i = value.Length - 1; i >= 0; i--) {
byte b = value [i];
@@ -2580,6 +2590,8 @@ namespace System {
private static string ConvertToBase8 (byte[] value)
{
+ if (!BitConverter.IsLittleEndian)
+ EndianSwap (ref value);
ulong l = 0;
switch (value.Length) {
case 1:
@@ -2612,6 +2624,8 @@ namespace System {
private static string ConvertToBase16 (byte[] value)
{
+ if (!BitConverter.IsLittleEndian)
+ EndianSwap (ref value);
StringBuilder sb = new StringBuilder ();
for (int i = value.Length - 1; i >= 0; i--) {
char high = (char)((value[i] >> 4) & 0x0f);
@@ -2672,8 +2686,12 @@ namespace System {
internal static object ToType (object value, Type conversionType,
IFormatProvider provider)
{
- if (value == null)
- return null;
+ if (value == null) {
+ if ((conversionType != null) && conversionType.IsValueType)
+ throw new InvalidCastException ("Null object can not be converted to a value type.");
+ else
+ return null;
+ }
if (conversionType == null)
throw new InvalidCastException ("Cannot cast to destination type.");
@@ -2739,12 +2757,7 @@ namespace System {
else if (conversionType == conversionTable[18]) // 18 TypeCode.String
return (object) convertValue.ToString (provider);
else {
- try {
- return (object) convertValue;
- }
- catch {
- throw new ArgumentException (Locale.GetText ("Unknown target conversion type"));
- }
+ throw new ArgumentException (Locale.GetText ("Unknown target conversion type"));
}
} else
// Not in the conversion table
diff --git a/mcs/class/corlib/System/DateTime.cs b/mcs/class/corlib/System/DateTime.cs
index cb90d719a98..188d0d27bd4 100644
--- a/mcs/class/corlib/System/DateTime.cs
+++ b/mcs/class/corlib/System/DateTime.cs
@@ -1007,8 +1007,10 @@ namespace System
num = 1;
}
- if (hour >= 12)
+ if (hour > 12)
return false;
+ if (hour == 12)
+ hour = 0;
break;
case 'H':
@@ -1188,6 +1190,22 @@ namespace System
s = s.Substring (num_parsed);
+ if (!exact) {
+ switch (chars [pos]) {
+ case 'm':
+ case 's':
+ case 'f':
+ case 'z':
+ if (s.Length > 0 && s [0] == 'Z'
+ && (pos + 1 == chars.Length
+ || chars [pos + 1] != 'Z')) {
+ useutc = true;
+ s = s.Substring (1);
+ }
+ break;
+ }
+ }
+
pos = pos + num + 1;
num = 0;
}
diff --git a/mcs/class/corlib/System/Environment.cs b/mcs/class/corlib/System/Environment.cs
index bf213ff4cb7..c21030f8b35 100644
--- a/mcs/class/corlib/System/Environment.cs
+++ b/mcs/class/corlib/System/Environment.cs
@@ -290,8 +290,8 @@ namespace System
PlatformID platform = Platform;
StringBuilder result = new StringBuilder ();
result.Append (name, 0, off1);
+ Hashtable tbl = null;
do {
- Hashtable tbl = null;
string var = name.Substring (off1 + 1, off2 - off1 - 1);
string value = GetEnvironmentVariable (var);
if (value == null && (int) platform != 128) {
diff --git a/mcs/class/corlib/System/Random.cs b/mcs/class/corlib/System/Random.cs
index 3bc3e23498b..e730865d76e 100644
--- a/mcs/class/corlib/System/Random.cs
+++ b/mcs/class/corlib/System/Random.cs
@@ -74,7 +74,7 @@ namespace System
}
}
inext = 0;
- inextp = 21;
+ inextp = 31;
}
protected virtual double Sample ()
diff --git a/mcs/class/corlib/System/Version.cs b/mcs/class/corlib/System/Version.cs
index ea64cde7080..adc86fa5568 100644
--- a/mcs/class/corlib/System/Version.cs
+++ b/mcs/class/corlib/System/Version.cs
@@ -152,7 +152,12 @@ namespace System
public object Clone ()
{
- return new Version (_Major, _Minor, _Build, _Revision);
+ if (_Build == -1)
+ return new Version (_Major, _Minor);
+ else if (_Revision == -1)
+ return new Version (_Major, _Minor, _Build);
+ else
+ return new Version (_Major, _Minor, _Build, _Revision);
}
public int CompareTo (object version)
diff --git a/mcs/class/corlib/Test/System/ChangeLog b/mcs/class/corlib/Test/System/ChangeLog
index b271ba154f9..6d419bfee33 100644
--- a/mcs/class/corlib/Test/System/ChangeLog
+++ b/mcs/class/corlib/Test/System/ChangeLog
@@ -1,3 +1,13 @@
+2004-09-23 Martin Garton <martin@wrasse.demon.co.uk>
+
+ * ConvertTest.cs: Ensure ToType() fails with an ArgumentException in
+ a case where is cannot convert.
+
+2004-08-17 Sebastien Pouliot <sebastien@ximian.com>
+
+ * VersionTest.cs: Added tests when cloning a version with no build and
+ no revision numbers (-1).
+
2004-06-23 Sebastien Pouliot <sebastien@ximian.com>
* DoubleFormatterTest.cs: Added a new test for a negative roundtrip
diff --git a/mcs/class/corlib/Test/System/ConvertTest.cs b/mcs/class/corlib/Test/System/ConvertTest.cs
index bafdffdb566..44e5f547567 100755
--- a/mcs/class/corlib/Test/System/ConvertTest.cs
+++ b/mcs/class/corlib/Test/System/ConvertTest.cs
@@ -189,7 +189,17 @@ namespace MonoTests.System {
}
catch (Exception e) {
AssertEquals("#A33", typeof(ArgumentNullException), e.GetType());
- }
+ }
+
+ try {
+ /* should fail to convert string to any enumeration type. */
+ Convert.ChangeType("random string", typeof(DayOfWeek));
+ Fail();
+ }
+ catch (Exception e) {
+ AssertEquals("#A34", typeof(ArgumentException), e.GetType());
+ }
+
}
public void TestGetTypeCode() {
diff --git a/mcs/class/corlib/Test/System/VersionTest.cs b/mcs/class/corlib/Test/System/VersionTest.cs
index 635a485cadc..2467d963a48 100644
--- a/mcs/class/corlib/Test/System/VersionTest.cs
+++ b/mcs/class/corlib/Test/System/VersionTest.cs
@@ -135,6 +135,12 @@ public class VersionTest : TestCase
Assert ("A1", v1.Equals (v2));
Assert ("A2", !ReferenceEquals (v1, v2));
+
+ Version v3 = new Version (); // 0.0
+ v2 = (Version) v3.Clone ();
+
+ Assert ("A3", v3.Equals (v2));
+ Assert ("A4", !ReferenceEquals (v3, v2));
}
public void TestCompareTo ()
diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources
index 4a49234f3f2..c1a958a1308 100755
--- a/mcs/class/corlib/corlib.dll.sources
+++ b/mcs/class/corlib/corlib.dll.sources
@@ -307,6 +307,8 @@ System.IO/StringReader.cs
System.IO/StringWriter.cs
System.IO/TextReader.cs
System.IO/TextWriter.cs
+System.IO/UnexceptionalStreamReader.cs
+System.IO/UnexceptionalStreamWriter.cs
System.IO.IsolatedStorage/INormalizeForIsolatedStorage.cs
System.IO.IsolatedStorage/IsolatedStorage.cs
System.IO.IsolatedStorage/IsolatedStorageException.cs