You've already forked linux-packaging-mono
Imported Upstream version 4.0.1
Former-commit-id: 757121caeaad523350be5330f0a3ecc891c70fb8
This commit is contained in:
@@ -407,7 +407,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
int numArrayItems = Math.Min(chunkSize/typeLength, array.Length-arrayOffset);
|
||||
int bufferUsed = numArrayItems*typeLength;
|
||||
Buffer.InternalBlockCopy(array, arrayOffset*typeLength, byteBuffer, 0, bufferUsed);
|
||||
#if BIGENDIAN
|
||||
if (!BitConverter.IsLittleEndian) {
|
||||
// we know that we are writing a primitive type, so just do a simple swap
|
||||
for (int i = 0; i < bufferUsed; i += typeLength)
|
||||
{
|
||||
@@ -418,7 +418,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
byteBuffer[i + typeLength-1 - j] = tmp;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
WriteBytes(byteBuffer, 0, bufferUsed);
|
||||
arrayOffset += numArrayItems;
|
||||
}
|
||||
|
@@ -158,12 +158,12 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
bIsCrossAppDomain = isCrossAppDomain;
|
||||
#endif
|
||||
bSimpleAssembly = (formatterEnums.FEassemblyFormat == FormatterAssemblyStyle.Simple);
|
||||
|
||||
#if !MONO
|
||||
if (fCheck)
|
||||
{
|
||||
CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
|
||||
}
|
||||
|
||||
#endif
|
||||
this.handler = handler;
|
||||
|
||||
Contract.Assert(!bFullDeserialization, "we just set bFullDeserialization to false");
|
||||
@@ -244,12 +244,12 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
bIsCrossAppDomain = isCrossAppDomain;
|
||||
#endif
|
||||
bSimpleAssembly = (formatterEnums.FEassemblyFormat == FormatterAssemblyStyle.Simple);
|
||||
|
||||
#if !MONO
|
||||
if (fCheck)
|
||||
{
|
||||
CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
|
||||
}
|
||||
|
||||
#endif
|
||||
this.handler = handler;
|
||||
|
||||
|
||||
@@ -1504,9 +1504,10 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
if ( !FormatterServices.UnsafeTypeForwardersIsEnabled() && sourceAssembly != destAssembly )
|
||||
{
|
||||
// we have a type forward to attribute !
|
||||
|
||||
#if !DISABLE_CAS_USE
|
||||
// we can try to see if the dest assembly has less permissionSet
|
||||
if (!destAssembly.PermissionSet.IsSubsetOf(sourceAssembly.PermissionSet))
|
||||
#endif
|
||||
{
|
||||
// let us try to see if typeforwardedfrom is there
|
||||
|
||||
@@ -1521,17 +1522,20 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
typeFowardedFromAssembly = Assembly.Load(typeInfo.AssemblyString);
|
||||
}
|
||||
catch { }
|
||||
|
||||
#if !DISABLE_CAS_USE
|
||||
if (typeFowardedFromAssembly != sourceAssembly)
|
||||
{
|
||||
// throw security exception
|
||||
throw new SecurityException() { Demanded = sourceAssembly.PermissionSet };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !DISABLE_CAS_USE
|
||||
// throw security exception
|
||||
throw new SecurityException() { Demanded = sourceAssembly.PermissionSet };
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -85,12 +85,12 @@ namespace System.Runtime.Serialization.Formatters.Binary
|
||||
Contract.EndContractBlock();
|
||||
|
||||
SerTrace.Log(this, "Serialize Entry 2 ", graph, ((headers == null) ? " no headers " : "headers "));
|
||||
|
||||
#if !MONO
|
||||
if (fCheck)
|
||||
{
|
||||
CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
|
||||
}
|
||||
|
||||
#endif
|
||||
this.serWriter = serWriter;
|
||||
this.headers = inHeaders;
|
||||
|
||||
|
@@ -1031,7 +1031,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
int numArrayItems = Math.Min(chunkSize/typeLength, array.Length-arrayOffset);
|
||||
int bufferUsed = numArrayItems*typeLength;
|
||||
ReadBytes(byteBuffer, 0, bufferUsed);
|
||||
#if BIGENDIAN
|
||||
if (!BitConverter.IsLittleEndian) {
|
||||
// we know that we are reading a primitive type, so just do a simple swap
|
||||
for (int i = 0; i < bufferUsed; i += typeLength)
|
||||
{
|
||||
@@ -1042,7 +1042,7 @@ namespace System.Runtime.Serialization.Formatters.Binary {
|
||||
byteBuffer[i + typeLength - 1 - j] = tmp;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Buffer.InternalBlockCopy(byteBuffer, 0, array, arrayOffset*typeLength, bufferUsed);
|
||||
arrayOffset += numArrayItems;
|
||||
}
|
||||
|
@@ -294,6 +294,17 @@ namespace System.Runtime.Serialization {
|
||||
}
|
||||
}
|
||||
|
||||
#if MONO
|
||||
private static Object nativeGetUninitializedObject(RuntimeType type)
|
||||
{
|
||||
return System.Runtime.Remoting.Activation.ActivationServices.AllocateUninitializedClassInstance (type);
|
||||
}
|
||||
|
||||
private static Object nativeGetSafeUninitializedObject(RuntimeType type)
|
||||
{
|
||||
return System.Runtime.Remoting.Activation.ActivationServices.AllocateUninitializedClassInstance (type);
|
||||
}
|
||||
#else
|
||||
[System.Security.SecurityCritical] // auto-generated
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
@@ -303,11 +314,19 @@ namespace System.Runtime.Serialization {
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
private static extern Object nativeGetUninitializedObject(RuntimeType type);
|
||||
#endif
|
||||
#if FEATURE_SERIALIZATION
|
||||
#if MONO
|
||||
static bool GetEnableUnsafeTypeForwarders ()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
[System.Security.SecurityCritical]
|
||||
[ResourceExposure(ResourceScope.None)]
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
private static extern bool GetEnableUnsafeTypeForwarders();
|
||||
#endif
|
||||
|
||||
[SecuritySafeCritical]
|
||||
internal static bool UnsafeTypeForwardersIsEnabled()
|
||||
|
@@ -53,6 +53,7 @@ namespace System.Runtime.Serialization
|
||||
}
|
||||
else if (RemotingServices.IsTransparentProxy(serObj) || serObj is MarshalByRefObject)
|
||||
{
|
||||
#if !MONO
|
||||
// We can only try to smuggle objref's for actual CLR objects
|
||||
// or for RemotingProxy's.
|
||||
if (!RemotingServices.IsTransparentProxy(serObj) ||
|
||||
@@ -78,7 +79,7 @@ namespace System.Runtime.Serialization
|
||||
retObj = objRef;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
if (retObj == null)
|
||||
{
|
||||
// Deal with the non-smugglable remoting objects
|
||||
|
@@ -53,7 +53,9 @@ namespace System.Runtime.Serialization {
|
||||
[System.Security.SecurityCritical] // auto-generated
|
||||
internal ObjectManager(ISurrogateSelector selector, StreamingContext context, bool checkSecurity, bool isCrossAppDomain) {
|
||||
if (checkSecurity) {
|
||||
#if !MONO
|
||||
CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
|
||||
#endif
|
||||
}
|
||||
m_objects = new ObjectHolder[DefaultInitialSize];
|
||||
m_selector = selector;
|
||||
|
@@ -184,7 +184,9 @@ namespace System.Runtime.Serialization
|
||||
{
|
||||
if (!IsAssemblyNameAssignmentSafe(originalAssemblyName, newAssemblyName))
|
||||
{
|
||||
#if !MONO
|
||||
CodeAccessPermission.Demand(PermissionType.SecuritySerialization);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user