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

Unified Diff: chrome/browser/safe_browsing/protocol_parser_unittest.cc

Issue 10216006: Use the correct remaining data length when parsing chunk headers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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
« no previous file with comments | « chrome/browser/safe_browsing/protocol_parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/protocol_parser_unittest.cc
diff --git a/chrome/browser/safe_browsing/protocol_parser_unittest.cc b/chrome/browser/safe_browsing/protocol_parser_unittest.cc
index 8b7abe32528a6343c44abd8ded9b2916b6aa2e5c..ca53694af3ca23e63bbaf5c9dc475df53d708823 100644
--- a/chrome/browser/safe_browsing/protocol_parser_unittest.cc
+++ b/chrome/browser/safe_browsing/protocol_parser_unittest.cc
@@ -223,6 +223,21 @@ TEST(SafeBrowsingProtocolParsingTest, TestTruncatedUrlHashChunk) {
EXPECT_EQ(chunks.size(), 0U);
}
+// Test to verify handling of a truncated chunk header.
+TEST(SafeBrowsingProtocolParsingTest, TestTruncatedHeader) {
+ std::string truncated_chunks("a:1:4:0\na:");
+
+ // Run the parser.
+ SafeBrowsingProtocolParser parser;
+ SBChunkList chunks;
+ bool result = parser.ParseChunk(
+ safe_browsing_util::kMalwareList,
+ truncated_chunks.data(),
+ static_cast<int>(truncated_chunks.length()),
+ &chunks);
+ EXPECT_FALSE(result);
+}
+
// Test parsing one sub chunk.
TEST(SafeBrowsingProtocolParsingTest, TestSubChunk) {
std::string sub_chunk("s:9:4:59\naaaaxkkkk1111\003"
« no previous file with comments | « chrome/browser/safe_browsing/protocol_parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698