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 82cbce79d935fc9f6ebf720dddd52df9f2fc9d92..9c5ea88e66b58e2ed78d0d1474d641bb3f74f34b 100644 |
--- a/chrome/browser/safe_browsing/protocol_parser.cc |
+++ b/chrome/browser/safe_browsing/protocol_parser.cc |
@@ -131,6 +131,23 @@ class BufferReader { |
DISALLOW_COPY_AND_ASSIGN(BufferReader); |
}; |
+bool ParseGetHashMetadata(size_t hash_count, BufferReader* reader) { |
+ for (size_t i = 0; i < hash_count; ++i) { |
+ base::StringPiece line; |
+ if (!reader->GetLine(&line)) |
+ return false; |
+ |
+ size_t meta_data_len; |
+ if (!base::StringToSizeT(line, &meta_data_len)) |
+ return false; |
+ |
+ const void* meta_data; |
+ if (!reader->RefData(&meta_data, meta_data_len)) |
+ return false; |
+ } |
+ return true; |
+} |
+ |
} // namespace |
namespace safe_browsing { |
@@ -206,6 +223,8 @@ 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)) |
noé
2014/09/18 20:41:07
nit: can you add a TODO here to send the metadata
mattm
2014/09/18 20:50:32
Done.
I need to pull that out of my old api 2.3
|
+ return false; |
continue; |
} |
@@ -216,21 +235,8 @@ bool ParseGetHash(const char* chunk_data, |
} |
// Discard the metadata for now. |
- if (has_metadata) { |
- for (size_t i = 0; i < hash_count; ++i) { |
- base::StringPiece line; |
- if (!reader.GetLine(&line)) |
- return false; |
- |
- size_t meta_data_len; |
- if (!base::StringToSizeT(line, &meta_data_len)) |
- return false; |
- |
- const void* meta_data; |
- if (!reader.RefData(&meta_data, meta_data_len)) |
- return false; |
- } |
- } |
+ if (has_metadata && !ParseGetHashMetadata(hash_count, &reader)) |
+ return false; |
} |
return reader.empty(); |