Title: [113041] trunk/Source/WebKit2
Revision
113041
Author
[email protected]
Date
2012-04-03 08:45:02 -0700 (Tue, 03 Apr 2012)

Log Message

[Qt][WK2] ASSERT(!(outputBytes.size() % sizeof(UChar))) in PluginProcessProxyQt.cpp
https://bugs.webkit.org/show_bug.cgi?id=83034

Reviewed by Zoltan Herczeg.

Don't allow the plugin to pollute the standard output.
Reinvent StdOutDevNullRedirector which was removed in
r112889 for this purpose.

* Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp:
(StdoutDevNullRedirector):
(WebKit):
(WebKit::StdoutDevNullRedirector::StdoutDevNullRedirector):
(WebKit::StdoutDevNullRedirector::~StdoutDevNullRedirector):
(WebKit::NetscapePluginModule::scanPlugin):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (113040 => 113041)


--- trunk/Source/WebKit2/ChangeLog	2012-04-03 15:37:16 UTC (rev 113040)
+++ trunk/Source/WebKit2/ChangeLog	2012-04-03 15:45:02 UTC (rev 113041)
@@ -1,3 +1,21 @@
+2012-04-03  Balazs Kelemen  <[email protected]>
+
+        [Qt][WK2] ASSERT(!(outputBytes.size() % sizeof(UChar))) in PluginProcessProxyQt.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=83034
+
+        Reviewed by Zoltan Herczeg.
+
+        Don't allow the plugin to pollute the standard output.
+        Reinvent StdOutDevNullRedirector which was removed in
+        r112889 for this purpose.
+
+        * Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp:
+        (StdoutDevNullRedirector):
+        (WebKit):
+        (WebKit::StdoutDevNullRedirector::StdoutDevNullRedirector):
+        (WebKit::StdoutDevNullRedirector::~StdoutDevNullRedirector):
+        (WebKit::NetscapePluginModule::scanPlugin):
+
 2012-04-02  Jocelyn Turcotte  <[email protected]>
 
         Enable and connect the WebInspectorServer with WebKit2 pages.

Modified: trunk/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp (113040 => 113041)


--- trunk/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp	2012-04-03 15:37:16 UTC (rev 113040)
+++ trunk/Source/WebKit2/Shared/Plugins/Netscape/x11/NetscapePluginModuleX11.cpp	2012-04-03 15:45:02 UTC (rev 113041)
@@ -41,6 +41,32 @@
 
 namespace WebKit {
 
+class StdoutDevNullRedirector {
+public:
+    StdoutDevNullRedirector();
+    ~StdoutDevNullRedirector();
+
+private:
+    int m_savedStdout;
+};
+
+StdoutDevNullRedirector::StdoutDevNullRedirector()
+    : m_savedStdout(-1)
+{
+    int newStdout = open("/dev/null", O_WRONLY);
+    if (newStdout == -1)
+        return;
+    m_savedStdout = dup(STDOUT_FILENO);
+    dup2(newStdout, STDOUT_FILENO);
+}
+
+StdoutDevNullRedirector::~StdoutDevNullRedirector()
+{
+    if (m_savedStdout != -1)
+        dup2(m_savedStdout, STDOUT_FILENO);
+}
+
+
 static void parseMIMEDescription(const String& mimeDescription, Vector<MimeClassInfo>& result)
 {
     ASSERT_ARG(result, result.isEmpty());
@@ -154,20 +180,26 @@
 
 bool NetscapePluginModule::scanPlugin(const String& pluginPath)
 {
-    // We are loading the plugin here since it does not seem to be a standardized way to
-    // get the needed informations from a UNIX plugin without loading it.
-    RefPtr<NetscapePluginModule> pluginModule = NetscapePluginModule::getOrCreate(pluginPath);
-    if (!pluginModule)
-        return false;
-
-    pluginModule->incrementLoadCount();
     RawPluginMetaData metaData;
-    bool success = pluginModule->getPluginInfoForLoadedPlugin(metaData);
-    pluginModule->decrementLoadCount();
 
-    if (!success)
-        return false;
+    {
+        // Don't allow the plugin to pollute the standard output.
+        StdoutDevNullRedirector stdOutRedirector;
 
+        // We are loading the plugin here since it does not seem to be a standardized way to
+        // get the needed informations from a UNIX plugin without loading it.
+        RefPtr<NetscapePluginModule> pluginModule = NetscapePluginModule::getOrCreate(pluginPath);
+        if (!pluginModule)
+            return false;
+
+        pluginModule->incrementLoadCount();
+        bool success = pluginModule->getPluginInfoForLoadedPlugin(metaData);
+        pluginModule->decrementLoadCount();
+
+        if (!success)
+            return false;
+    }
+
     // Write data to standard output for the UI process.
     String output[3] = {
         truncateToSingleLine(metaData.name),
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to