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

Unified Diff: content/browser/service_worker/service_worker_database.cc

Issue 1135743002: Check the size of ResourceRecords in ServiceWorkerDatabase::ReadRegistration() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK in ServiceWorkerStorage::ReturnFoundRegistration() Created 5 years, 7 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
Index: content/browser/service_worker/service_worker_database.cc
diff --git a/content/browser/service_worker/service_worker_database.cc b/content/browser/service_worker/service_worker_database.cc
index fca967cf830e8081ddeb5d20e2f2bab5de766379..c928c38751c4929848b1bd301720fecd0df2f986 100644
--- a/content/browser/service_worker/service_worker_database.cc
+++ b/content/browser/service_worker/service_worker_database.cc
@@ -538,6 +538,10 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::ReadRegistration(
if (status != STATUS_OK)
return status;
+ // ResourceRecord must contain the ServiceWorker's main script.
+ if (resources->empty())
+ return ServiceWorkerDatabase::STATUS_ERROR_CORRUPTED;
+
*registration = value;
return STATUS_OK;
}
@@ -583,6 +587,7 @@ ServiceWorkerDatabase::Status ServiceWorkerDatabase::WriteRegistration(
std::vector<int64>* newly_purgeable_resources) {
DCHECK(sequence_checker_.CalledOnValidSequencedThread());
DCHECK(old_registration);
+ DCHECK(!resources.empty());
Status status = LazyOpen(true);
old_registration->version_id = kInvalidServiceWorkerVersionId;
if (status != STATUS_OK)

Powered by Google App Engine
This is Rietveld 408576698