Title: [184413] trunk/Source
Revision
184413
Author
[email protected]
Date
2015-05-15 13:48:21 -0700 (Fri, 15 May 2015)

Log Message

[Content Extensions] Fail to load old content extension files
https://bugs.webkit.org/show_bug.cgi?id=145027

Reviewed by Eric Carlson.

Source/WebCore:

* contentextensions/DFABytecode.h:

Source/WebKit2:

* UIProcess/API/APIUserContentExtensionStore.cpp:
(API::openAndMapContentExtension):
* UIProcess/API/APIUserContentExtensionStore.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (184412 => 184413)


--- trunk/Source/WebCore/ChangeLog	2015-05-15 20:47:16 UTC (rev 184412)
+++ trunk/Source/WebCore/ChangeLog	2015-05-15 20:48:21 UTC (rev 184413)
@@ -1,3 +1,12 @@
+2015-05-15  Alex Christensen  <[email protected]>
+
+        [Content Extensions] Fail to load old content extension files
+        https://bugs.webkit.org/show_bug.cgi?id=145027
+
+        Reviewed by Eric Carlson.
+
+        * contentextensions/DFABytecode.h:
+
 2015-05-15  Eric Carlson  <[email protected]>
 
         Unreviewed build fix.

Modified: trunk/Source/WebCore/contentextensions/DFABytecode.h (184412 => 184413)


--- trunk/Source/WebCore/contentextensions/DFABytecode.h	2015-05-15 20:47:16 UTC (rev 184412)
+++ trunk/Source/WebCore/contentextensions/DFABytecode.h	2015-05-15 20:48:21 UTC (rev 184413)
@@ -34,6 +34,9 @@
 
 typedef uint8_t DFABytecode;
 
+// Increment UserContentExtensionStore::CurrentContentExtensionFileVersion
+// when making any non-backwards-compatible changes to the bytecode.
+// FIXME: Changes here should not require changes in WebKit2.  Move all versioning to WebCore.
 enum class DFABytecodeInstruction : uint8_t {
 
     // CheckValue has two arguments:

Modified: trunk/Source/WebKit2/ChangeLog (184412 => 184413)


--- trunk/Source/WebKit2/ChangeLog	2015-05-15 20:47:16 UTC (rev 184412)
+++ trunk/Source/WebKit2/ChangeLog	2015-05-15 20:48:21 UTC (rev 184413)
@@ -1,3 +1,14 @@
+2015-05-15  Alex Christensen  <[email protected]>
+
+        [Content Extensions] Fail to load old content extension files
+        https://bugs.webkit.org/show_bug.cgi?id=145027
+
+        Reviewed by Eric Carlson.
+
+        * UIProcess/API/APIUserContentExtensionStore.cpp:
+        (API::openAndMapContentExtension):
+        * UIProcess/API/APIUserContentExtensionStore.h:
+
 2015-05-15  Jeremy Jones  <[email protected]>
 
         Limit alternate fullscreen with linked on or after.

Modified: trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp (184412 => 184413)


--- trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp	2015-05-15 20:47:16 UTC (rev 184412)
+++ trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp	2015-05-15 20:48:21 UTC (rev 184413)
@@ -76,7 +76,7 @@
 
 const size_t ContentExtensionFileHeaderSize = sizeof(uint32_t) + 4 * sizeof(uint64_t);
 struct ContentExtensionMetaData {
-    uint32_t version { 2 };
+    uint32_t version { UserContentExtensionStore::CurrentContentExtensionFileVersion };
     uint64_t actionsSize { 0 };
     uint64_t filtersWithoutDomainsBytecodeSize { 0 };
     uint64_t filtersWithDomainBytecodeSize { 0 };
@@ -325,6 +325,13 @@
             return;
         }
         
+        if (metaData.version != UserContentExtensionStore::CurrentContentExtensionFileVersion) {
+            RunLoop::main().dispatch([self, completionHandler] {
+                completionHandler(nullptr, Error::VersionMismatch);
+            });
+            return;
+        }
+        
         RunLoop::main().dispatch([self, identifierCapture, fileData, metaData, completionHandler] {
             RefPtr<API::UserContentExtension> userContentExtension = createExtension(identifierCapture.string(), metaData, fileData);
             completionHandler(userContentExtension, { });
@@ -400,6 +407,8 @@
             switch (static_cast<UserContentExtensionStore::Error>(errorCode)) {
             case UserContentExtensionStore::Error::LookupFailed:
                 return "Unspecified error during lookup.";
+            case UserContentExtensionStore::Error::VersionMismatch:
+                return "Version of file does not match version of interpreter.";
             case UserContentExtensionStore::Error::CompileFailed:
                 return "Unspecified error during compile.";
             case UserContentExtensionStore::Error::RemoveFailed:

Modified: trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h (184412 => 184413)


--- trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h	2015-05-15 20:47:16 UTC (rev 184412)
+++ trunk/Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.h	2015-05-15 20:48:21 UTC (rev 184413)
@@ -44,9 +44,14 @@
 public:
     enum class Error {
         LookupFailed = 1,
+        VersionMismatch,
         CompileFailed,
         RemoveFailed
     };
+    
+    // This should be incremented every time a functional change is made to the bytecode, file format, etc.
+    // to prevent crashing while loading old data.
+    const static uint32_t CurrentContentExtensionFileVersion = 2;
 
     static UserContentExtensionStore& defaultStore();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to