Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Unified Diff: ipc/ipc_message_utils_unittest.cc

Issue 2968003005: Support Serializing and Deserializing RepeatedField / RepeatedPtrField in IPC::Message (Closed)
Patch Set: Update IsPickleSizeSufficent to avoid GetSize Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ipc/ipc_message_utils_unittest.cc
diff --git a/ipc/ipc_message_utils_unittest.cc b/ipc/ipc_message_utils_unittest.cc
index 867768089ba845888e1396232f3933483d811072..c1b83e62e99f933abd59e5ac0e58c3fa5845238d 100644
--- a/ipc/ipc_message_utils_unittest.cc
+++ b/ipc/ipc_message_utils_unittest.cc
@@ -255,5 +255,27 @@ TEST(IPCMessageUtilsTest, FlatMap) {
EXPECT_EQ(input, output);
}
+TEST(IPCMessageUtilsTest, InvalidPickleShouldNotCrashFlatMapDeserialization) {
+ base::Pickle pickle;
+ IPC::WriteParam(&pickle, INT_MAX);
+ IPC::WriteParam(&pickle, 0);
+ IPC::WriteParam(&pickle, 0);
+
+ base::PickleIterator iter(pickle);
+ base::flat_map<int, int> output;
+ EXPECT_FALSE(IPC::ReadParam(&pickle, &iter, &output));
+}
+
+TEST(IPCMessageUtilsTest, InvalidPickleShouldNotCrashMapDeserialization) {
+ base::Pickle pickle;
+ IPC::WriteParam(&pickle, INT_MAX);
+ IPC::WriteParam(&pickle, 0);
+ IPC::WriteParam(&pickle, 0);
+
+ base::PickleIterator iter(pickle);
+ std::map<int, int> output;
+ EXPECT_FALSE(IPC::ReadParam(&pickle, &iter, &output));
+}
+
} // namespace
} // namespace IPC
« ipc/ipc_message_utils.h ('K') | « ipc/ipc_message_utils.cc ('k') | ipc/test_proto.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698