Title: [143791] trunk/Source/WebCore
Revision
143791
Author
[email protected]
Date
2013-02-22 14:07:44 -0800 (Fri, 22 Feb 2013)

Log Message

Add some checks to DatabaseTracker::getMaxSizeForDatabase() to ensure
that it returns a sane value.
https://bugs.webkit.org/show_bug.cgi?id=110557.

Reviewed by Geoffrey Garen.

No layout test, but there is a quota-test.html attached to bugzilla.
The test is a webpage that can be loaded into multiple tabs to
consuming storage space. Once the test webpages are loaded, you will
need to monitor the database directory and its files to confirm that
growth is bounded. Also try reloading the test in the tabs. At no
time should any database file ever exceed the quota.

* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::getMaxSizeForDatabase):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (143790 => 143791)


--- trunk/Source/WebCore/ChangeLog	2013-02-22 22:06:51 UTC (rev 143790)
+++ trunk/Source/WebCore/ChangeLog	2013-02-22 22:07:44 UTC (rev 143791)
@@ -1,3 +1,21 @@
+2013-02-21  Mark Lam  <[email protected]>
+
+        Add some checks to DatabaseTracker::getMaxSizeForDatabase() to ensure
+        that it returns a sane value.
+        https://bugs.webkit.org/show_bug.cgi?id=110557.
+
+        Reviewed by Geoffrey Garen.
+
+        No layout test, but there is a quota-test.html attached to bugzilla.
+        The test is a webpage that can be loaded into multiple tabs to
+        consuming storage space. Once the test webpages are loaded, you will
+        need to monitor the database directory and its files to confirm that
+        growth is bounded. Also try reloading the test in the tabs. At no
+        time should any database file ever exceed the quota.
+
+        * Modules/webdatabase/DatabaseTracker.cpp:
+        (WebCore::DatabaseTracker::getMaxSizeForDatabase):
+
 2013-02-22  James Simonsen  <[email protected]>
 
         Preloads should be cleared when _javascript_ cancels loading prematurely.

Modified: trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp (143790 => 143791)


--- trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp	2013-02-22 22:06:51 UTC (rev 143790)
+++ trunk/Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp	2013-02-22 22:07:44 UTC (rev 143791)
@@ -290,7 +290,19 @@
     MutexLocker lockDatabase(m_databaseGuard);
     Locker<OriginQuotaManager> quotaManagerLocker(originQuotaManager());
     SecurityOrigin* origin = database->securityOrigin();
-    return quotaForOriginNoLock(origin) - originQuotaManager().diskUsage(origin) + SQLiteFileSystem::getDatabaseFileSize(database->fileName());
+
+    unsigned long long quota = quotaForOriginNoLock(origin);
+    unsigned long long diskUsage = originQuotaManager().diskUsage(origin);
+    unsigned long long databaseFileSize = SQLiteFileSystem::getDatabaseFileSize(database->fileName());
+
+    // A previous error may have allowed the origin to exceed its quota, or may
+    // have allowed this database to exceed our cached estimate of the origin
+    // disk usage. Don't multiply that error through integer underflow, or the
+    // effective quota will permanently become 2^64.
+    unsigned long long maxSize = quota - diskUsage + databaseFileSize;
+    if (maxSize > quota)
+        maxSize = 0;
+    return maxSize;
 }
 
 void DatabaseTracker::databaseChanged(DatabaseBackendBase* database)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to