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

Unified Diff: components/precache/core/precache_manifest_util.cc

Issue 2820713002: precache: Add the check for a minimum length of manifest bitset. (Closed)
Patch Set: Created 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/precache/core/precache_manifest_util.cc
diff --git a/components/precache/core/precache_manifest_util.cc b/components/precache/core/precache_manifest_util.cc
index 668a77fecb2c3e1f8e8dccd189c3ae428902d25e..ab801f651632657b8791ab3cc88794fe59d2ee5e 100644
--- a/components/precache/core/precache_manifest_util.cc
+++ b/components/precache/core/precache_manifest_util.cc
@@ -36,19 +36,26 @@ base::Optional<std::vector<bool>> GetResourceBitset(
if (it != resource_bitset_map.end()) {
if (it->second.has_bitset()) {
const std::string& bitset = it->second.bitset();
- ret.emplace(bitset.size() * 8);
- for (size_t i = 0; i < bitset.size(); ++i) {
- for (size_t j = 0; j < 8; ++j) {
- if ((1 << j) & bitset[i])
- ret.value()[i * 8 + j] = true;
+ const int bitset_size = bitset.size() * 8;
+ DCHECK_GE(bitset_size, manifest.resource_size());
+ if (bitset_size >= manifest.resource_size()) {
+ ret.emplace(bitset_size);
+ for (size_t i = 0; i < bitset.size(); ++i) {
+ for (size_t j = 0; j < 8; ++j) {
+ if ((1 << j) & bitset[i])
+ ret.value()[i * 8 + j] = true;
+ }
}
}
} else if (it->second.has_deprecated_bitset()) {
uint64_t bitset = it->second.deprecated_bitset();
- ret.emplace(64);
- for (int i = 0; i < 64; ++i) {
- if ((0x1ULL << i) & bitset)
- ret.value()[i] = true;
+ DCHECK_GE(64, manifest.resource_size());
+ if (64 >= manifest.resource_size()) {
+ ret.emplace(64);
+ for (int i = 0; i < 64; ++i) {
+ if ((0x1ULL << i) & bitset)
+ ret.value()[i] = true;
+ }
}
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698