aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/CodedInputStream.cs
diff options
context:
space:
mode:
authorFeng Xiao <xfxyjwf@gmail.com>2018-03-14 13:25:19 -0700
committerGitHub <noreply@github.com>2018-03-14 13:25:19 -0700
commit813848d19d58fac043485b61a92e84dcf1a23b56 (patch)
treefba00c0181044d5be124631a3b20ffb596abf6ac /csharp/src/Google.Protobuf/CodedInputStream.cs
parentd5f5725c0a57913fe7842f49522b9e64c6dae525 (diff)
parent864df890a7639dae59a8ccad06a767adeb7210a3 (diff)
downloadprotobuf-813848d19d58fac043485b61a92e84dcf1a23b56.tar.gz
protobuf-813848d19d58fac043485b61a92e84dcf1a23b56.tar.bz2
protobuf-813848d19d58fac043485b61a92e84dcf1a23b56.zip
Merge pull request #4222 from JohnHBrock/increasing_max_csharp_message_size
Remove 64MB memory limit when deserializing messages in C#
Diffstat (limited to 'csharp/src/Google.Protobuf/CodedInputStream.cs')
-rw-r--r--csharp/src/Google.Protobuf/CodedInputStream.cs6
1 files changed, 3 insertions, 3 deletions
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;
/// <summary>
@@ -248,7 +248,7 @@ namespace Google.Protobuf
/// <remarks>
/// 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.
/// </remarks>
/// <value>
/// 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();
}