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

Unified Diff: base/metrics/persistent_memory_allocator.cc

Issue 1654053002: New test and off-by-one fix for data persisted to disk. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: allow crash-test to run with dcheck enabled Created 4 years, 10 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 | base/metrics/persistent_memory_allocator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/metrics/persistent_memory_allocator.cc
diff --git a/base/metrics/persistent_memory_allocator.cc b/base/metrics/persistent_memory_allocator.cc
index 4ab8f8c8c3f72cdeee6526318ca2c948715f0ddc..a1c28c659d3b2921c389b6efe794d65015658487 100644
--- a/base/metrics/persistent_memory_allocator.cc
+++ b/base/metrics/persistent_memory_allocator.cc
@@ -163,7 +163,6 @@ PersistentMemoryAllocator::PersistentMemoryAllocator(void* base,
if (shared_meta()->cookie != kGlobalCookie) {
if (readonly) {
- NOTREACHED();
SetCorrupt();
return;
}
@@ -215,10 +214,7 @@ PersistentMemoryAllocator::PersistentMemoryAllocator(void* base,
strcpy(name_cstr, name.c_str());
}
} else {
- if (readonly) {
- // For read-only access, validate reasonable ctor parameters.
- DCHECK_GE(mem_size_, shared_meta()->freeptr.load());
- } else {
+ if (!readonly) {
// The allocator is attaching to a previously initialized segment of
// memory. Make sure the embedded data matches what has been passed.
if (shared_meta()->size != mem_size_ ||
@@ -282,7 +278,7 @@ size_t PersistentMemoryAllocator::GetAllocSize(Reference ref) const {
uint32_t size = block->size;
// Header was verified by GetBlock() but a malicious actor could change
// the value between there and here. Check it again.
- if (size <= sizeof(BlockHeader) || ref + size >= mem_size_) {
+ if (size <= sizeof(BlockHeader) || ref + size > mem_size_) {
SetCorrupt();
return 0;
}
« no previous file with comments | « no previous file | base/metrics/persistent_memory_allocator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698