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

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

Issue 586793003: Safebrowsing: Honor the metadata from malware fullhash results in SB API 3.0. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes for sky Created 6 years, 3 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: chrome/browser/safe_browsing/protocol_parser.cc
diff --git a/chrome/browser/safe_browsing/protocol_parser.cc b/chrome/browser/safe_browsing/protocol_parser.cc
index 790dda554f1decef871d1582adcd2fb3d448c8f4..05378c465205c89097006c6d9d15b3b92733972f 100644
--- a/chrome/browser/safe_browsing/protocol_parser.cc
+++ b/chrome/browser/safe_browsing/protocol_parser.cc
@@ -131,7 +131,9 @@ class BufferReader {
DISALLOW_COPY_AND_ASSIGN(BufferReader);
};
-bool ParseGetHashMetadata(size_t hash_count, BufferReader* reader) {
+bool ParseGetHashMetadata(size_t hash_count,
+ BufferReader* reader,
+ std::vector<SBFullHashResult>* full_hashes) {
for (size_t i = 0; i < hash_count; ++i) {
base::StringPiece line;
if (!reader->GetLine(&line))
@@ -144,6 +146,11 @@ bool ParseGetHashMetadata(size_t hash_count, BufferReader* reader) {
const void* meta_data;
if (!reader->RefData(&meta_data, meta_data_len))
return false;
+
+ if (full_hashes) {
+ (*full_hashes)[full_hashes->size() - hash_count + i].metadata.assign(
+ reinterpret_cast<const char*>(meta_data), meta_data_len);
+ }
}
return true;
}
@@ -223,7 +230,7 @@ bool ParseGetHash(const char* chunk_data,
// Ignore hash results from lists we don't recognize.
if (full_hash.list_id < 0) {
reader.Advance(hash_len * hash_count);
- if (has_metadata && !ParseGetHashMetadata(hash_count, &reader))
+ if (has_metadata && !ParseGetHashMetadata(hash_count, &reader, NULL))
return false;
continue;
}
@@ -234,9 +241,7 @@ bool ParseGetHash(const char* chunk_data,
full_hashes->push_back(full_hash);
}
- // Discard the metadata for now.
- // TODO(mattm): handle the metadata (see crbug.com/176648).
- if (has_metadata && !ParseGetHashMetadata(hash_count, &reader))
+ if (has_metadata && !ParseGetHashMetadata(hash_count, &reader, full_hashes))
return false;
}
« no previous file with comments | « chrome/browser/safe_browsing/metadata.proto ('k') | chrome/browser/safe_browsing/protocol_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698