Commit 1755fa3e authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

Add end() check to fix security bug

Fix the bug by checking we have not reached the
end before accessing.

BUG=1095560

Change-Id: I309237562ddd5058c3b3b99d58a03c526cf49b6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276511
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784113}
parent affe0911
......@@ -157,8 +157,10 @@ void MediaHistoryKeyedService::OnURLsDeleted(
const auto& origin_count =
deletion_info.deleted_urls_origin_map().find(origin.GetURL());
if (origin_count->second.first > 0)
if (origin_count == deletion_info.deleted_urls_origin_map().end() ||
origin_count->second.first > 0) {
continue;
}
deleted_origins.insert(origin);
}
......
......@@ -1012,4 +1012,17 @@ TEST_P(MediaHistoryKeyedServiceTest, CleanUpDatabaseWhenURLIsDeleted) {
}
}
TEST_P(MediaHistoryKeyedServiceTest, SecurityRegressionTest) {
history::URLRows urls_to_delete = {
history::URLRow(GURL("https://www.google.com/test1A"))};
history::DeletionInfo deletion_info =
history::DeletionInfo::ForUrls(urls_to_delete, std::set<GURL>());
deletion_info.set_deleted_urls_origin_map({
{GURL("https://www.google.com/test1B"), {0, base::Time::Now()}},
{GURL("https://www.google.com/test1C"), {0, base::Time::Now()}},
});
service()->OnURLsDeleted(nullptr, deletion_info);
}
} // namespace media_history
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