Commit 13f56c0d authored by csharptest's avatar csharptest Committed by rogerk

amended: Add SecurityCritical attributes to serialization

parent 6ab2678e
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
/* /*
* This entire source file is not supported on some platform * This entire source file is not supported on some platform
*/ */
using System.Security.Permissions;
#if !NOSERIALIZABLE #if !NOSERIALIZABLE
using System; using System;
using System.Runtime.Serialization; using System.Runtime.Serialization;
...@@ -52,6 +53,7 @@ namespace Google.ProtocolBuffers ...@@ -52,6 +53,7 @@ namespace Google.ProtocolBuffers
partial class AbstractMessageLite<TMessage, TBuilder> : ISerializable partial class AbstractMessageLite<TMessage, TBuilder> : ISerializable
{ {
[SecurityCritical] [SecurityCritical]
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{ {
info.SetType(typeof(SerializationSurrogate)); info.SetType(typeof(SerializationSurrogate));
...@@ -72,6 +74,8 @@ namespace Google.ProtocolBuffers ...@@ -72,6 +74,8 @@ namespace Google.ProtocolBuffers
_initialized = info.GetBoolean("initialized"); _initialized = info.GetBoolean("initialized");
} }
[SecurityCritical]
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
object IObjectReference.GetRealObject(StreamingContext context) object IObjectReference.GetRealObject(StreamingContext context)
{ {
ExtensionRegistry registry = context.Context as ExtensionRegistry; ExtensionRegistry registry = context.Context as ExtensionRegistry;
...@@ -95,6 +99,7 @@ namespace Google.ProtocolBuffers ...@@ -95,6 +99,7 @@ namespace Google.ProtocolBuffers
} }
[SecurityCritical] [SecurityCritical]
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{ {
info.AddValue("message", _message); info.AddValue("message", _message);
...@@ -106,6 +111,7 @@ namespace Google.ProtocolBuffers ...@@ -106,6 +111,7 @@ namespace Google.ProtocolBuffers
partial class AbstractBuilderLite<TMessage, TBuilder> : ISerializable partial class AbstractBuilderLite<TMessage, TBuilder> : ISerializable
{ {
[SecurityCritical] [SecurityCritical]
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{ {
info.SetType(typeof(SerializationSurrogate)); info.SetType(typeof(SerializationSurrogate));
...@@ -123,6 +129,8 @@ namespace Google.ProtocolBuffers ...@@ -123,6 +129,8 @@ namespace Google.ProtocolBuffers
_message = (byte[])info.GetValue("message", typeof(byte[])); _message = (byte[])info.GetValue("message", typeof(byte[]));
} }
[SecurityCritical]
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
object IObjectReference.GetRealObject(StreamingContext context) object IObjectReference.GetRealObject(StreamingContext context)
{ {
ExtensionRegistry registry = context.Context as ExtensionRegistry; ExtensionRegistry registry = context.Context as ExtensionRegistry;
...@@ -139,6 +147,7 @@ namespace Google.ProtocolBuffers ...@@ -139,6 +147,7 @@ namespace Google.ProtocolBuffers
} }
[SecurityCritical] [SecurityCritical]
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{ {
info.AddValue("message", _message); info.AddValue("message", _message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment