]> Pileus Git - ~andy/sunrise/blob - www-client/torbrowser/files/11.0/0007-Block-all-plugins-except-flash.patch
b850f62a07741f4bfb9a5cc28db914a575eb87dc
[~andy/sunrise] / www-client / torbrowser / files / 11.0 / 0007-Block-all-plugins-except-flash.patch
1 From 10873c626d038b520853539d45a170919d6d0361 Mon Sep 17 00:00:00 2001
2 From: Mike Perry <mikeperry-git@torproject.org>
3 Date: Wed, 1 Feb 2012 15:50:15 -0800
4 Subject: [PATCH 07/13] Block all plugins except flash.
5
6 We cannot use the @mozilla.org/extensions/blocklist;1 service, because we
7 actually want to stop plugins from ever entering the browser's process space
8 and/or executing code (for example, AV plugins that collect statistics/analyse
9 urls, magical toolbars that phone home or "help" the user, skype buttons that
10 ruin our day, and censorship filters). Hence we rolled our own.
11
12 See https://trac.torproject.org/projects/tor/ticket/3547#comment:6 for musings
13 on a better way. Until then, it is delta-darwinism for us.
14 ---
15  dom/plugins/base/nsPluginHost.cpp |   33 +++++++++++++++++++++++++++++++++
16  dom/plugins/base/nsPluginHost.h   |    2 ++
17  2 files changed, 35 insertions(+), 0 deletions(-)
18
19 diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp
20 index 7fe18b2..d76c4ca 100644
21 --- a/dom/plugins/base/nsPluginHost.cpp
22 +++ b/dom/plugins/base/nsPluginHost.cpp
23 @@ -1982,6 +1982,35 @@ bool nsPluginHost::IsDuplicatePlugin(nsPluginTag * aPluginTag)
24    return false;
25  }
26  
27 +PRBool nsPluginHost::GhettoBlacklist(nsIFile *pluginFile)
28 +{
29 +    nsCString leaf;
30 +    const char *leafStr;
31 +    nsresult rv;
32 +    
33 +    rv = pluginFile->GetNativeLeafName(leaf);
34 +    if (NS_FAILED(rv)) {
35 +        return PR_TRUE; // fuck 'em. blacklist.
36 +    }
37 +
38 +    leafStr = leaf.get();
39 +
40 +    if (!leafStr) {
41 +        return PR_TRUE; // fuck 'em. blacklist.
42 +    }
43 +
44 +    // libgnashplugin.so, libflashplayer.so, Flash Player-10.4-10.5.plugin,
45 +    // NPSWF32.dll, NPSWF64.dll
46 +    if (strstr(leafStr, "libgnashplugin") == leafStr ||
47 +        strstr(leafStr, "libflashplayer") == leafStr ||
48 +        strstr(leafStr, "Flash Player") == leafStr ||
49 +        strstr(leafStr, "NPSWF") == leafStr) {
50 +        return PR_FALSE;
51 +    }
52 +
53 +    return PR_TRUE; // fuck 'em. blacklist.
54 +}
55 +
56  typedef NS_NPAPIPLUGIN_CALLBACK(char *, NP_GETMIMEDESCRIPTION)(void);
57  
58  nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
59 @@ -2103,6 +2132,10 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir,
60        continue;
61      }
62  
63 +    if (GhettoBlacklist(localfile)) {
64 +        continue;
65 +    }
66 +
67      // if it is not found in cache info list or has been changed, create a new one
68      if (!pluginTag) {
69        nsPluginFile pluginFile(localfile);
70 diff --git a/dom/plugins/base/nsPluginHost.h b/dom/plugins/base/nsPluginHost.h
71 index 5630b8d..f54bd32 100644
72 --- a/dom/plugins/base/nsPluginHost.h
73 +++ b/dom/plugins/base/nsPluginHost.h
74 @@ -285,6 +285,8 @@ private:
75    // Loads all cached plugins info into mCachedPlugins
76    nsresult ReadPluginInfo();
77  
78 +  PRBool GhettoBlacklist(nsIFile *pluginFile);
79 +
80    // Given a file path, returns the plugins info from our cache
81    // and removes it from the cache.
82    void RemoveCachedPluginsInfo(const char *filePath,
83 -- 
84 1.7.5.4
85