From 864df890a7639dae59a8ccad06a767adeb7210a3 Mon Sep 17 00:00:00 2001 From: John Brock Date: Wed, 24 Jan 2018 17:22:18 -0800 Subject: Remove 64MB memory limit when deserializing messages in C# Increased `CodedInputStream.DefaultSizeLimit` to `Int32.MaxValue` to make it consistent with the Java implementation. --- csharp/src/Google.Protobuf/CodedInputStream.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'csharp/src/Google.Protobuf/CodedInputStream.cs') diff --git a/csharp/src/Google.Protobuf/CodedInputStream.cs b/csharp/src/Google.Protobuf/CodedInputStream.cs index 6bee238f..0a829545 100644 --- a/csharp/src/Google.Protobuf/CodedInputStream.cs +++ b/csharp/src/Google.Protobuf/CodedInputStream.cs @@ -94,7 +94,7 @@ namespace Google.Protobuf private bool hasNextTag = false; internal const int DefaultRecursionLimit = 64; - internal const int DefaultSizeLimit = 64 << 20; // 64MB + internal const int DefaultSizeLimit = Int32.MaxValue; internal const int BufferSize = 4096; /// @@ -248,7 +248,7 @@ namespace Google.Protobuf /// /// This limit is applied when reading from the underlying stream, as a sanity check. It is /// not applied when reading from a byte array data source without an underlying stream. - /// The default value is 64MB. + /// The default value is Int32.MaxValue. /// /// /// The size limit. @@ -1058,7 +1058,7 @@ namespace Google.Protobuf RecomputeBufferSizeAfterLimit(); int totalBytesRead = totalBytesRetired + bufferSize + bufferSizeAfterLimit; - if (totalBytesRead > sizeLimit || totalBytesRead < 0) + if (totalBytesRead < 0 || totalBytesRead > sizeLimit) { throw InvalidProtocolBufferException.SizeLimitExceeded(); } -- cgit v1.2.3