From 14c700fa668060549ebd2e8a7c230f99f52f7ffd Mon Sep 17 00:00:00 2001 From: James Ko Date: Tue, 5 Jul 2016 10:58:26 -0400 Subject: [PATCH] Move the SecuritySafeCritical attributes to EncodingForwarder Commit migrated from https://github.com/dotnet/coreclr/commit/a64020c8825770ccc8a83d200783a979fbac6434 --- src/coreclr/src/mscorlib/src/System/Text/ASCIIEncoding.cs | 7 ------- .../src/mscorlib/src/System/Text/EncodingForwarder.cs | 12 ++++++++++++ src/coreclr/src/mscorlib/src/System/Text/EncodingNLS.cs | 7 ------- src/coreclr/src/mscorlib/src/System/Text/UTF32Encoding.cs | 7 ------- src/coreclr/src/mscorlib/src/System/Text/UTF7Encoding.cs | 7 ------- src/coreclr/src/mscorlib/src/System/Text/UTF8Encoding.cs | 7 ------- src/coreclr/src/mscorlib/src/System/Text/UnicodeEncoding.cs | 7 ------- 7 files changed, 12 insertions(+), 42 deletions(-) diff --git a/src/coreclr/src/mscorlib/src/System/Text/ASCIIEncoding.cs b/src/coreclr/src/mscorlib/src/System/Text/ASCIIEncoding.cs index 4e2b798..ab5fa77 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/ASCIIEncoding.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/ASCIIEncoding.cs @@ -57,13 +57,11 @@ namespace System.Text // Returns the number of bytes required to encode a range of characters in // a character array. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetByteCount(char[] chars, int index, int count) { return EncodingForwarder.GetByteCount(this, chars, index, count); } - [System.Security.SecuritySafeCritical] // auto-generated public override int GetByteCount(String chars) { return EncodingForwarder.GetByteCount(this, chars); @@ -77,7 +75,6 @@ namespace System.Text return EncodingForwarder.GetByteCount(this, chars, count); } - [System.Security.SecuritySafeCritical] // auto-generated public override int GetBytes(String chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { @@ -93,7 +90,6 @@ namespace System.Text // determine the maximum number of bytes that will be produced for a given // number of characters, regardless of the actual character values. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { @@ -111,7 +107,6 @@ namespace System.Text // Returns the number of characters produced by decoding a range of bytes // in a byte array. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetCharCount(byte[] bytes, int index, int count) { return EncodingForwarder.GetCharCount(this, bytes, index, count); @@ -125,7 +120,6 @@ namespace System.Text return EncodingForwarder.GetCharCount(this, bytes, count); } - [System.Security.SecuritySafeCritical] // auto-generated public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { @@ -143,7 +137,6 @@ namespace System.Text // Returns a string containing the decoded representation of a range of // bytes in a byte array. - [System.Security.SecuritySafeCritical] // auto-generated public override String GetString(byte[] bytes, int byteIndex, int byteCount) { return EncodingForwarder.GetString(this, bytes, byteIndex, byteCount); diff --git a/src/coreclr/src/mscorlib/src/System/Text/EncodingForwarder.cs b/src/coreclr/src/mscorlib/src/System/Text/EncodingForwarder.cs index e0d6986..7bc217d 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/EncodingForwarder.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/EncodingForwarder.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Diagnostics.Contracts; +using System.Security; namespace System.Text { @@ -30,6 +31,7 @@ namespace System.Text // the parameter, it will call the same method again, which will eventually // lead to a StackOverflowException. + [SecuritySafeCritical] public unsafe static int GetByteCount(Encoding encoding, char[] chars, int index, int count) { // Validate parameters @@ -58,6 +60,7 @@ namespace System.Text return encoding.GetByteCount(pChars + index, count, encoder: null); } + [SecuritySafeCritical] public unsafe static int GetByteCount(Encoding encoding, string s) { Contract.Assert(encoding != null); @@ -81,6 +84,7 @@ namespace System.Text return encoding.GetByteCount(pChars, s.Length, encoder: null); } + [SecurityCritical] public unsafe static int GetByteCount(Encoding encoding, char* chars, int count) { Contract.Assert(encoding != null); @@ -98,6 +102,7 @@ namespace System.Text return encoding.GetByteCount(chars, count, encoder: null); } + [SecuritySafeCritical] public unsafe static int GetBytes(Encoding encoding, string s, int charIndex, int charCount, byte[] bytes, int byteIndex) { Contract.Assert(encoding != null); @@ -137,6 +142,7 @@ namespace System.Text } } + [SecuritySafeCritical] public unsafe static int GetBytes(Encoding encoding, char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { Contract.Assert(encoding != null); @@ -177,6 +183,7 @@ namespace System.Text } } + [SecurityCritical] public unsafe static int GetBytes(Encoding encoding, char* chars, int charCount, byte* bytes, int byteCount) { Contract.Assert(encoding != null); @@ -193,6 +200,7 @@ namespace System.Text return encoding.GetBytes(chars, charCount, bytes, byteCount, encoder: null); } + [SecuritySafeCritical] public unsafe static int GetCharCount(Encoding encoding, byte[] bytes, int index, int count) { Contract.Assert(encoding != null); @@ -219,6 +227,7 @@ namespace System.Text return encoding.GetCharCount(pBytes + index, count, decoder: null); } + [SecurityCritical] public unsafe static int GetCharCount(Encoding encoding, byte* bytes, int count) { Contract.Assert(encoding != null); @@ -235,6 +244,7 @@ namespace System.Text return encoding.GetCharCount(bytes, count, decoder: null); } + [SecuritySafeCritical] public unsafe static int GetChars(Encoding encoding, byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { Contract.Assert(encoding != null); @@ -273,6 +283,7 @@ namespace System.Text } } + [SecurityCritical] public unsafe static int GetChars(Encoding encoding, byte* bytes, int byteCount, char* chars, int charCount) { Contract.Assert(encoding != null); @@ -289,6 +300,7 @@ namespace System.Text return encoding.GetChars(bytes, byteCount, chars, charCount, decoder: null); } + [SecuritySafeCritical] public unsafe static string GetString(Encoding encoding, byte[] bytes, int index, int count) { Contract.Assert(encoding != null); diff --git a/src/coreclr/src/mscorlib/src/System/Text/EncodingNLS.cs b/src/coreclr/src/mscorlib/src/System/Text/EncodingNLS.cs index fa988cb..d670d6d 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/EncodingNLS.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/EncodingNLS.cs @@ -40,13 +40,11 @@ namespace System.Text // Returns the number of bytes required to encode a range of characters in // a character array. - [System.Security.SecuritySafeCritical] // overrides public transparent member public override int GetByteCount(char[] chars, int index, int count) { return EncodingForwarder.GetByteCount(this, chars, index, count); } - [System.Security.SecuritySafeCritical] // overrides public transparent member public override int GetByteCount(String s) { return EncodingForwarder.GetByteCount(this, s); @@ -58,7 +56,6 @@ namespace System.Text return EncodingForwarder.GetByteCount(this, chars, count); } - [System.Security.SecuritySafeCritical] // overrides public transparent member public override int GetBytes(String s, int charIndex, int charCount, byte[] bytes, int byteIndex) { @@ -74,7 +71,6 @@ namespace System.Text // determine the maximum number of bytes that will be produced for a given // number of characters, regardless of the actual character values. - [System.Security.SecuritySafeCritical] // overrides public transparent member public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { @@ -90,7 +86,6 @@ namespace System.Text // Returns the number of characters produced by decoding a range of bytes // in a byte array. - [System.Security.SecuritySafeCritical] // overrides public transparent member public override int GetCharCount(byte[] bytes, int index, int count) { return EncodingForwarder.GetCharCount(this, bytes, index, count); @@ -102,7 +97,6 @@ namespace System.Text return EncodingForwarder.GetCharCount(this, bytes, count); } - [System.Security.SecuritySafeCritical] // overrides public transparent member public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { @@ -118,7 +112,6 @@ namespace System.Text // Returns a string containing the decoded representation of a range of // bytes in a byte array. - [System.Security.SecuritySafeCritical] // overrides public transparent member public override String GetString(byte[] bytes, int index, int count) { return EncodingForwarder.GetString(this, bytes, index, count); diff --git a/src/coreclr/src/mscorlib/src/System/Text/UTF32Encoding.cs b/src/coreclr/src/mscorlib/src/System/Text/UTF32Encoding.cs index 0d875d3..cd7d0a9 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/UTF32Encoding.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/UTF32Encoding.cs @@ -95,13 +95,11 @@ namespace System.Text // Returns the number of bytes required to encode a range of characters in // a character array. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetByteCount(char[] chars, int index, int count) { return EncodingForwarder.GetByteCount(this, chars, index, count); } - [System.Security.SecuritySafeCritical] // auto-generated public override int GetByteCount(String s) { return EncodingForwarder.GetByteCount(this, s); @@ -114,7 +112,6 @@ namespace System.Text return EncodingForwarder.GetByteCount(this, chars, count); } - [System.Security.SecuritySafeCritical] // auto-generated public override int GetBytes(String s, int charIndex, int charCount, byte[] bytes, int byteIndex) { @@ -130,7 +127,6 @@ namespace System.Text // determine the maximum number of bytes that will be produced for a given // number of characters, regardless of the actual character values. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { @@ -147,7 +143,6 @@ namespace System.Text // Returns the number of characters produced by decoding a range of bytes // in a byte array. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetCharCount(byte[] bytes, int index, int count) { return EncodingForwarder.GetCharCount(this, bytes, index, count); @@ -160,7 +155,6 @@ namespace System.Text return EncodingForwarder.GetCharCount(this, bytes, count); } - [System.Security.SecuritySafeCritical] // auto-generated public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { @@ -177,7 +171,6 @@ namespace System.Text // Returns a string containing the decoded representation of a range of // bytes in a byte array. - [System.Security.SecuritySafeCritical] // auto-generated public override String GetString(byte[] bytes, int index, int count) { return EncodingForwarder.GetString(this, bytes, index, count); diff --git a/src/coreclr/src/mscorlib/src/System/Text/UTF7Encoding.cs b/src/coreclr/src/mscorlib/src/System/Text/UTF7Encoding.cs index 98e99ec..7c4f773 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/UTF7Encoding.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/UTF7Encoding.cs @@ -162,13 +162,11 @@ namespace System.Text // Returns the number of bytes required to encode a range of characters in // a character array. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetByteCount(char[] chars, int index, int count) { return EncodingForwarder.GetByteCount(this, chars, index, count); } - [System.Security.SecuritySafeCritical] // auto-generated [System.Runtime.InteropServices.ComVisible(false)] public override int GetByteCount(String s) { @@ -183,7 +181,6 @@ namespace System.Text return EncodingForwarder.GetByteCount(this, chars, count); } - [System.Security.SecuritySafeCritical] // auto-generated [System.Runtime.InteropServices.ComVisible(false)] public override int GetBytes(String s, int charIndex, int charCount, byte[] bytes, int byteIndex) @@ -200,7 +197,6 @@ namespace System.Text // determine the maximum number of bytes that will be produced for a given // number of characters, regardless of the actual character values. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { @@ -218,7 +214,6 @@ namespace System.Text // Returns the number of characters produced by decoding a range of bytes // in a byte array. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetCharCount(byte[] bytes, int index, int count) { return EncodingForwarder.GetCharCount(this, bytes, index, count); @@ -232,7 +227,6 @@ namespace System.Text return EncodingForwarder.GetCharCount(this, bytes, count); } - [System.Security.SecuritySafeCritical] // auto-generated public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { @@ -250,7 +244,6 @@ namespace System.Text // Returns a string containing the decoded representation of a range of // bytes in a byte array. - [System.Security.SecuritySafeCritical] // auto-generated [System.Runtime.InteropServices.ComVisible(false)] public override String GetString(byte[] bytes, int index, int count) { diff --git a/src/coreclr/src/mscorlib/src/System/Text/UTF8Encoding.cs b/src/coreclr/src/mscorlib/src/System/Text/UTF8Encoding.cs index fa6e957..8763799 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/UTF8Encoding.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/UTF8Encoding.cs @@ -115,13 +115,11 @@ namespace System.Text // Returns the number of bytes required to encode a range of characters in // a character array. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetByteCount(char[] chars, int index, int count) { return EncodingForwarder.GetByteCount(this, chars, index, count); } - [System.Security.SecuritySafeCritical] // auto-generated public override int GetByteCount(String chars) { return EncodingForwarder.GetByteCount(this, chars); @@ -135,7 +133,6 @@ namespace System.Text return EncodingForwarder.GetByteCount(this, chars, count); } - [System.Security.SecuritySafeCritical] // auto-generated public override int GetBytes(String s, int charIndex, int charCount, byte[] bytes, int byteIndex) { @@ -151,7 +148,6 @@ namespace System.Text // determine the maximum number of bytes that will be produced for a given // number of characters, regardless of the actual character values. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { @@ -169,7 +165,6 @@ namespace System.Text // Returns the number of characters produced by decoding a range of bytes // in a byte array. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetCharCount(byte[] bytes, int index, int count) { return EncodingForwarder.GetCharCount(this, bytes, index, count); @@ -183,7 +178,6 @@ namespace System.Text return EncodingForwarder.GetCharCount(this, bytes, count); } - [System.Security.SecuritySafeCritical] // auto-generated public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { @@ -201,7 +195,6 @@ namespace System.Text // Returns a string containing the decoded representation of a range of // bytes in a byte array. - [System.Security.SecuritySafeCritical] // auto-generated [System.Runtime.InteropServices.ComVisible(false)] public override String GetString(byte[] bytes, int index, int count) { diff --git a/src/coreclr/src/mscorlib/src/System/Text/UnicodeEncoding.cs b/src/coreclr/src/mscorlib/src/System/Text/UnicodeEncoding.cs index bab8fd2..7a6244a 100644 --- a/src/coreclr/src/mscorlib/src/System/Text/UnicodeEncoding.cs +++ b/src/coreclr/src/mscorlib/src/System/Text/UnicodeEncoding.cs @@ -94,13 +94,11 @@ namespace System.Text // Returns the number of bytes required to encode a range of characters in // a character array. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetByteCount(char[] chars, int index, int count) { return EncodingForwarder.GetByteCount(this, chars, index, count); } - [System.Security.SecuritySafeCritical] // auto-generated public override int GetByteCount(String s) { return EncodingForwarder.GetByteCount(this, s); @@ -114,7 +112,6 @@ namespace System.Text return EncodingForwarder.GetByteCount(this, chars, count); } - [System.Security.SecuritySafeCritical] // auto-generated public override int GetBytes(String s, int charIndex, int charCount, byte[] bytes, int byteIndex) { @@ -130,7 +127,6 @@ namespace System.Text // determine the maximum number of bytes that will be produced for a given // number of characters, regardless of the actual character values. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { @@ -148,7 +144,6 @@ namespace System.Text // Returns the number of characters produced by decoding a range of bytes // in a byte array. - [System.Security.SecuritySafeCritical] // auto-generated public override int GetCharCount(byte[] bytes, int index, int count) { return EncodingForwarder.GetCharCount(this, bytes, index, count); @@ -162,7 +157,6 @@ namespace System.Text return EncodingForwarder.GetCharCount(this, bytes, count); } - [System.Security.SecuritySafeCritical] // auto-generated public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { @@ -180,7 +174,6 @@ namespace System.Text // Returns a string containing the decoded representation of a range of // bytes in a byte array. - [System.Security.SecuritySafeCritical] // auto-generated [System.Runtime.InteropServices.ComVisible(false)] public override String GetString(byte[] bytes, int index, int count) { -- 2.7.4