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

Side by Side Diff: webkit/plugins/npapi/plugin_list_posix.cc

Issue 10823132: Linux: Add more selective plugin blacklisting code. Blacklist a plugin that fails to check for SSE2… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: I can spel Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/plugins/npapi/plugin_list.h" 5 #include "webkit/plugins/npapi/plugin_list.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/cpu.h"
9 #include "base/file_util.h" 10 #include "base/file_util.h"
10 #include "base/path_service.h" 11 #include "base/path_service.h"
11 #include "base/sha1.h" 12 #include "base/sha1.h"
12 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
13 #include "base/string_split.h" 14 #include "base/string_split.h"
14 #include "base/string_util.h" 15 #include "base/string_util.h"
15 #include "build/build_config.h" 16 #include "build/build_config.h"
16 17
17 namespace webkit { 18 namespace webkit {
18 namespace npapi { 19 namespace npapi {
19 20
20 namespace { 21 namespace {
21 22
22 // We build up a list of files and mtimes so we can sort them. 23 // We build up a list of files and mtimes so we can sort them.
23 typedef std::pair<FilePath, base::Time> FileAndTime; 24 typedef std::pair<FilePath, base::Time> FileAndTime;
24 typedef std::vector<FileAndTime> FileTimeList; 25 typedef std::vector<FileAndTime> FileTimeList;
25 26
27 enum PluginQuirk {
28 // No quirks - plugin is outright banned.
29 PLUGIN_QUIRK_NONE = 0,
30 // Plugin is using SSE2 instructions without checking for SSE2 instruction
31 // support. Ban the plugin if the system has no SSE2 support.
32 PLUGIN_QUIRK_MISSING_SSE2_CHECK = 1 << 0,
33 };
34
26 // Comparator used to sort by descending mtime then ascending filename. 35 // Comparator used to sort by descending mtime then ascending filename.
27 bool CompareTime(const FileAndTime& a, const FileAndTime& b) { 36 bool CompareTime(const FileAndTime& a, const FileAndTime& b) {
28 if (a.second == b.second) { 37 if (a.second == b.second) {
29 // Fall back on filename sorting, just to make the predicate valid. 38 // Fall back on filename sorting, just to make the predicate valid.
30 return a.first < b.first; 39 return a.first < b.first;
31 } 40 }
32 41
33 // Sort by mtime, descending. 42 // Sort by mtime, descending.
34 return a.second > b.second; 43 return a.second > b.second;
35 } 44 }
36 45
46 // Checks to see if the current environment meets any of the condtions set in
47 // |quirks|. Returns true if any of the conditions are met, or if |quirks| is
48 // PLUGIN_QUIRK_NONE.
49 bool CheckQuirks(PluginQuirk quirks) {
50 if (quirks == PLUGIN_QUIRK_NONE)
51 return true;
52
53 if ((quirks & PLUGIN_QUIRK_MISSING_SSE2_CHECK) != 0) {
54 base::CPU cpu;
55 if (!cpu.has_sse2())
56 return true;
57 }
58
59 return false;
60 }
61
37 // Return true if |path| matches a known (file size, sha1sum) pair. 62 // Return true if |path| matches a known (file size, sha1sum) pair.
63 // Also check against any PluginQuirks the bad plugin may have.
38 // The use of the file size is an optimization so we don't have to read in 64 // The use of the file size is an optimization so we don't have to read in
39 // the entire file unless we have to. 65 // the entire file unless we have to.
40 bool IsBlacklistedBySha1sum(const FilePath& path) { 66 bool IsBlacklistedBySha1sumAndQuirks(const FilePath& path) {
41 const struct BadEntry { 67 const struct BadEntry {
42 int64 size; 68 int64 size;
43 std::string sha1; 69 std::string sha1;
70 PluginQuirk quirks;
44 } bad_entries[] = { 71 } bad_entries[] = {
45 // Flash 9 r31 - http://crbug.com/29237 72 // Flash 9 r31 - http://crbug.com/29237
46 { 7040080, "fa5803061125ca47846713b34a26a42f1f1e98bb" }, 73 { 7040080, "fa5803061125ca47846713b34a26a42f1f1e98bb", PLUGIN_QUIRK_NONE },
47 // Flash 9 r48 - http://crbug.com/29237 74 // Flash 9 r48 - http://crbug.com/29237
48 { 7040036, "0c4b3768a6d4bfba003088e4b9090d381de1af2b" }, 75 { 7040036, "0c4b3768a6d4bfba003088e4b9090d381de1af2b", PLUGIN_QUIRK_NONE },
76 // Flash 11.2.202.236, 32-bit - http://crbug.com/140086
77 { 17406436, "1e07eac912faf9426c52a288c76c3b6238f90b6b",
78 PLUGIN_QUIRK_MISSING_SSE2_CHECK },
49 }; 79 };
50 80
51 int64 size; 81 int64 size;
52 if (!file_util::GetFileSize(path, &size)) 82 if (!file_util::GetFileSize(path, &size))
53 return false; 83 return false;
54 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(bad_entries); i++) { 84 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(bad_entries); i++) {
55 if (bad_entries[i].size != size) 85 if (bad_entries[i].size != size)
56 continue; 86 continue;
57 87
58 std::string file_content; 88 std::string file_content;
59 if (!file_util::ReadFileToString(path, &file_content)) 89 if (!file_util::ReadFileToString(path, &file_content))
60 continue; 90 continue;
61 std::string sha1 = base::SHA1HashString(file_content); 91 std::string sha1 = base::SHA1HashString(file_content);
62 std::string sha1_readable; 92 std::string sha1_readable;
63 for (size_t j = 0; j < sha1.size(); j++) 93 for (size_t j = 0; j < sha1.size(); j++)
64 base::StringAppendF(&sha1_readable, "%02x", sha1[j] & 0xFF); 94 base::StringAppendF(&sha1_readable, "%02x", sha1[j] & 0xFF);
65 if (bad_entries[i].sha1 == sha1_readable) 95 if (bad_entries[i].sha1 == sha1_readable)
66 return true; 96 return CheckQuirks(bad_entries[i].quirks);
67 } 97 }
68 return false; 98 return false;
69 } 99 }
70 100
71 // Some plugins are shells around other plugins; we prefer to use the 101 // Some plugins are shells around other plugins; we prefer to use the
72 // real plugin directly, if it's available. This function returns 102 // real plugin directly, if it's available. This function returns
73 // true if we should prefer other plugins over this one. We'll still 103 // true if we should prefer other plugins over this one. We'll still
74 // use a "undesirable" plugin if no other option is available. 104 // use a "undesirable" plugin if no other option is available.
75 bool IsUndesirablePlugin(const WebPluginInfo& info) { 105 bool IsUndesirablePlugin(const WebPluginInfo& info) {
76 std::string filename = info.path.BaseName().value(); 106 std::string filename = info.path.BaseName().value();
(...skipping 16 matching lines...) Expand all
93 bool IsBlacklistedPlugin(const FilePath& path) { 123 bool IsBlacklistedPlugin(const FilePath& path) {
94 const char* kBlackListedPlugins[] = { 124 const char* kBlackListedPlugins[] = {
95 "nppdf.so", // Adobe PDF 125 "nppdf.so", // Adobe PDF
96 }; 126 };
97 std::string filename = path.BaseName().value(); 127 std::string filename = path.BaseName().value();
98 for (size_t i = 0; i < arraysize(kBlackListedPlugins); i++) { 128 for (size_t i = 0; i < arraysize(kBlackListedPlugins); i++) {
99 if (filename.find(kBlackListedPlugins[i]) != std::string::npos) { 129 if (filename.find(kBlackListedPlugins[i]) != std::string::npos) {
100 return true; 130 return true;
101 } 131 }
102 } 132 }
103 return IsBlacklistedBySha1sum(path); 133 return IsBlacklistedBySha1sumAndQuirks(path);
104 } 134 }
105 135
106 } // namespace 136 } // namespace
107 137
108 void PluginList::PlatformInit() { 138 void PluginList::PlatformInit() {
109 } 139 }
110 140
111 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) { 141 void PluginList::GetPluginDirectories(std::vector<FilePath>* plugin_dirs) {
112 // See http://groups.google.com/group/chromium-dev/browse_thread/thread/7a70e5 fcbac786a9 142 // See http://groups.google.com/group/chromium-dev/browse_thread/thread/7a70e5 fcbac786a9
113 // for discussion. 143 // for discussion.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 295
266 // TODO(evanm): prefer the newest version of flash, etc. here? 296 // TODO(evanm): prefer the newest version of flash, etc. here?
267 297
268 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value(); 298 VLOG_IF(1, PluginList::DebugPluginLoading()) << "Using " << info.path.value();
269 299
270 return true; 300 return true;
271 } 301 }
272 302
273 } // namespace npapi 303 } // namespace npapi
274 } // namespace webkit 304 } // namespace webkit
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698