DiscardRemainingTag should check lower 4 bits against zero if it's 5th varint byte.

PiperOrigin-RevId: 557880065
pull/13558/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent 71a9ae2232
commit 7d1fd82091
  1. 16
      src/google/protobuf/message_unittest.inc

@ -1024,6 +1024,22 @@ TEST(MESSAGE_TEST_NAME, NonCanonicalTag) {
EXPECT_TRUE(message.ParseFromArray(encoded, sizeof(encoded)));
}
TEST(MESSAGE_TEST_NAME, Zero5BTag) {
UNITTEST::TestAllTypes message;
// optional_nested_message (18) LEN(6) with 5B but zero tag.
const char encoded[] = {'\222', 1, 6, '\200', '\200',
'\200', '\200', '\020', 0};
EXPECT_FALSE(message.ParseFromArray(encoded, sizeof(encoded)));
}
TEST(MESSAGE_TEST_NAME, Zero5BTagLazy) {
UNITTEST::TestAllTypes message;
// optional_lazy_message (27) LEN(6) with 5B but zero tag.
const char encoded[] = {'\332', 1, 6, '\200', '\200',
'\200', '\200', '\020', 0};
EXPECT_FALSE(message.ParseFromArray(encoded, sizeof(encoded)));
}
namespace {

Loading…
Cancel
Save