aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/wire_format_unittest.cc
diff options
context:
space:
mode:
authorGravatar Feng Xiao <xfxyjwf@gmail.com>2017-03-29 14:32:48 -0700
committerGravatar Feng Xiao <xfxyjwf@gmail.com>2017-03-29 14:33:05 -0700
commitd36c0c538a545fac5d9db6ba65c525246d4efa95 (patch)
tree3fd29af0f137dfaf5df892723e60600f674392b3 /src/google/protobuf/wire_format_unittest.cc
parent4a0dd03e52e09332c8fd0f8f26a8e0ae9f911182 (diff)
Down-integrate from google3.
Diffstat (limited to 'src/google/protobuf/wire_format_unittest.cc')
-rw-r--r--src/google/protobuf/wire_format_unittest.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/google/protobuf/wire_format_unittest.cc b/src/google/protobuf/wire_format_unittest.cc
index 897fec00..cafe9a48 100644
--- a/src/google/protobuf/wire_format_unittest.cc
+++ b/src/google/protobuf/wire_format_unittest.cc
@@ -1029,6 +1029,29 @@ TEST_F(WireFormatInvalidInputTest, InvalidSubMessage) {
EXPECT_FALSE(message.ParseFromString(MakeInvalidEmbeddedMessage("\017", 1)));
}
+TEST_F(WireFormatInvalidInputTest, InvalidMessageWithExtraZero) {
+ string data;
+ {
+ // Serialize a valid proto
+ unittest::TestAllTypes message;
+ message.set_optional_int32(1);
+ message.SerializeToString(&data);
+ data.push_back(0); // Append invalid zero tag
+ }
+
+ // Control case.
+ {
+ io::ArrayInputStream ais(data.data(), data.size());
+ io::CodedInputStream is(&ais);
+ unittest::TestAllTypes message;
+ // It should fail but currently passes.
+ EXPECT_TRUE(message.MergePartialFromCodedStream(&is));
+ // Parsing from the string should fail.
+ EXPECT_FALSE(message.ParseFromString(data));
+ }
+}
+
+
TEST_F(WireFormatInvalidInputTest, InvalidGroup) {
unittest::TestAllTypes message;