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

Unified Diff: base/pickle_unittest.cc

Issue 4716006: Pickle: handle invalid data on 64 bit systems.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
« no previous file with comments | « base/pickle.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/pickle_unittest.cc
===================================================================
--- base/pickle_unittest.cc (revision 65620)
+++ base/pickle_unittest.cc (working copy)
@@ -87,6 +87,39 @@
VerifyResult(pickle3);
}
+// Tests that we can handle really small buffers.
+TEST(PickleTest, SmallBuffer) {
+ scoped_array<char> buffer(new char[1]);
+
+ // We should not touch the buffer.
+ Pickle pickle(buffer.get(), 1);
+
+ void* iter = NULL;
+ int data;
+ EXPECT_FALSE(pickle.ReadInt(&iter, &data));
+}
+
+// Tests that we can handle improper headers.
+TEST(PickleTest, BigSize) {
+ int buffer[] = { 0x56035200, 25, 40, 50 };
+
+ Pickle pickle(reinterpret_cast<char*>(buffer), sizeof(buffer));
+
+ void* iter = NULL;
+ int data;
+ EXPECT_FALSE(pickle.ReadInt(&iter, &data));
+}
+
+TEST(PickleTest, UnalignedSize) {
+ int buffer[] = { 10, 25, 40, 50 };
+
+ Pickle pickle(reinterpret_cast<char*>(buffer), sizeof(buffer));
+
+ void* iter = NULL;
+ int data;
+ EXPECT_FALSE(pickle.ReadInt(&iter, &data));
+}
+
TEST(PickleTest, ZeroLenStr) {
Pickle pickle;
EXPECT_TRUE(pickle.WriteString(""));
« no previous file with comments | « base/pickle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698