Add a check to ensure that the byte limit is not negative.

PiperOrigin-RevId: 632284538
pull/16812/head
Protobuf Team Bot 7 months ago committed by Copybara-Service
parent eb31de3097
commit af1ecc0353
  1. 3
      java/core/src/main/java/com/google/protobuf/CodedInputStream.java

@ -2690,6 +2690,9 @@ public abstract class CodedInputStream {
throw InvalidProtocolBufferException.negativeSize();
}
byteLimit += totalBytesRetired + pos;
if (byteLimit < 0) {
throw InvalidProtocolBufferException.parseFailure();
}
final int oldLimit = currentLimit;
if (byteLimit > oldLimit) {
throw InvalidProtocolBufferException.truncatedMessage();

Loading…
Cancel
Save