File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
java/core/src/main/java/com/google/protobuf Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -1184,7 +1184,8 @@ public int pushLimit(int byteLimit) throws InvalidProtocolBufferException {
11841184 }
11851185 byteLimit += getTotalBytesRead ();
11861186 if (byteLimit < 0 ) {
1187- throw InvalidProtocolBufferException .parseFailure ();
1187+ // Check for for integer overflow in byteLimit
1188+ throw InvalidProtocolBufferException .sizeLimitExceeded ();
11881189 }
11891190 final int oldLimit = currentLimit ;
11901191 if (byteLimit > oldLimit ) {
@@ -2679,7 +2680,8 @@ public int pushLimit(int byteLimit) throws InvalidProtocolBufferException {
26792680 }
26802681 byteLimit += totalBytesRetired + pos ;
26812682 if (byteLimit < 0 ) {
2682- throw InvalidProtocolBufferException .parseFailure ();
2683+ // Check for for integer overflow in byteLimit
2684+ throw InvalidProtocolBufferException .sizeLimitExceeded ();
26832685 }
26842686 final int oldLimit = currentLimit ;
26852687 if (byteLimit > oldLimit ) {
Original file line number Diff line number Diff line change @@ -137,8 +137,9 @@ static InvalidProtocolBufferException recursionLimitExceeded() {
137137
138138 static InvalidProtocolBufferException sizeLimitExceeded () {
139139 return new InvalidProtocolBufferException (
140- "Protocol message was too large. May be malicious. "
141- + "Use CodedInputStream.setSizeLimit() to increase the size limit." );
140+ "Protocol message was too large. May be malicious. Use CodedInputStream.setSizeLimit() to"
141+ + " increase the size limit. If reading multiple messages, consider resetting the"
142+ + " counter between each message using CodedInputStream.resetSizeCounter()." );
142143 }
143144
144145 static InvalidProtocolBufferException parseFailure () {
You can’t perform that action at this time.
0 commit comments