Commit fbdce5f5 authored by Brian White's avatar Brian White Committed by Commit Bot

Capture the size of an existing file for allocator size.

There are checks inside the PMA that limit any passed size to whatever
was defined when the memory segment was created.  But that could be
wrong if the segment is corrupted.

Bug: 749223
Change-Id: Ib0f5416e4c43b597b15e2cb05b3787677e5c0ea1
Reviewed-on: https://chromium-review.googlesource.com/596487
Commit-Queue: Brian White <bcwhite@chromium.org>
Reviewed-by: default avatarSteven Holte <holte@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491502}
parent 9869d2f1
......@@ -21,6 +21,7 @@
#include "base/metrics/persistent_sample_map.h"
#include "base/metrics/sparse_histogram.h"
#include "base/metrics/statistics_recorder.h"
#include "base/numerics/safe_conversions.h"
#include "base/pickle.h"
#include "base/strings/stringprintf.h"
#include "base/synchronization/lock.h"
......@@ -779,6 +780,7 @@ bool GlobalHistogramAllocator::CreateWithFile(
std::unique_ptr<MemoryMappedFile> mmfile(new MemoryMappedFile());
if (exists) {
size = saturated_cast<size_t>(file.GetLength());
mmfile->Initialize(std::move(file), MemoryMappedFile::READ_WRITE);
} else {
mmfile->Initialize(std::move(file), {0, static_cast<int64_t>(size)},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment