summaryrefslogtreecommitdiffstats
path: root/webkit/plugins
diff options
context:
space:
mode:
authorcevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-11 08:39:49 +0000
committercevans@chromium.org <cevans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-11 08:39:49 +0000
commit960eec66d4556b8ea9791ccf25e2ee15df8663b8 (patch)
tree7b8adcb842168a38a84ff9a2a543f201fcb6e17a /webkit/plugins
parenteec44d941cb60efe51454b593984199b7827d212 (diff)
downloadchromium_src-960eec66d4556b8ea9791ccf25e2ee15df8663b8.zip
chromium_src-960eec66d4556b8ea9791ccf25e2ee15df8663b8.tar.gz
chromium_src-960eec66d4556b8ea9791ccf25e2ee15df8663b8.tar.bz2
Re-land: add support for blocking out-of-date plug-ins on Linux.
BUG=NONE TEST=plugin_group_unittest.cc,plugin_lib_unittest.cc TBR=bauerb@chromium.org Review URL: http://codereview.chromium.org/6205004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71024 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/plugins')
-rw-r--r--webkit/plugins/npapi/plugin_group.cc4
-rw-r--r--webkit/plugins/npapi/plugin_group_unittest.cc15
-rw-r--r--webkit/plugins/npapi/plugin_lib.h5
-rw-r--r--webkit/plugins/npapi/plugin_lib_posix.cc45
-rw-r--r--webkit/plugins/npapi/plugin_lib_unittest.cc22
-rw-r--r--webkit/plugins/npapi/plugin_list.cc47
6 files changed, 120 insertions, 18 deletions
diff --git a/webkit/plugins/npapi/plugin_group.cc b/webkit/plugins/npapi/plugin_group.cc
index 23b0abc0..6323998 100644
--- a/webkit/plugins/npapi/plugin_group.cc
+++ b/webkit/plugins/npapi/plugin_group.cc
@@ -181,8 +181,7 @@ bool PluginGroup::Match(const WebPluginInfo& plugin) const {
}
// There's at least one version range, the plugin's version must be in it.
- scoped_ptr<Version> plugin_version(
- Version::GetVersionFromString(UTF16ToASCII(plugin.version)));
+ scoped_ptr<Version> plugin_version(CreateVersionFromString(plugin.version));
if (plugin_version.get() == NULL) {
// No version could be extracted, assume we don't match the range.
return false;
@@ -207,6 +206,7 @@ Version* PluginGroup::CreateVersionFromString(const string16& version_string) {
std::replace(version.begin(), version.end(), 'r', '.');
std::replace(version.begin(), version.end(), ',', '.');
std::replace(version.begin(), version.end(), '(', '.');
+ std::replace(version.begin(), version.end(), '_', '.');
return Version::GetVersionFromString(WideToASCII(version));
}
diff --git a/webkit/plugins/npapi/plugin_group_unittest.cc b/webkit/plugins/npapi/plugin_group_unittest.cc
index 3bda17c..6fc3db2 100644
--- a/webkit/plugins/npapi/plugin_group_unittest.cc
+++ b/webkit/plugins/npapi/plugin_group_unittest.cc
@@ -49,6 +49,9 @@ static const PluginGroupDefinition kPluginDefNotVulnerable = {
"myplugin-latest", "MyPlugin", "MyPlugin", NULL, 0, "http://latest" };
// name, path, version, desc.
+static WebPluginInfo kPluginNoVersion = WebPluginInfo(
+ ASCIIToUTF16("MyPlugin"), FilePath(FILE_PATH_LITERAL("myplugin.so.2.0.43")),
+ ASCIIToUTF16(""), ASCIIToUTF16("MyPlugin version 2.0.43"));
static WebPluginInfo kPlugin2043 = WebPluginInfo(
ASCIIToUTF16("MyPlugin"), FilePath(FILE_PATH_LITERAL("myplugin.so.2.0.43")),
ASCIIToUTF16("2.0.43"), ASCIIToUTF16("MyPlugin version 2.0.43"));
@@ -61,6 +64,9 @@ static WebPluginInfo kPlugin3044 = WebPluginInfo(
static WebPluginInfo kPlugin3045 = WebPluginInfo(
ASCIIToUTF16("MyPlugin"), FilePath(FILE_PATH_LITERAL("myplugin.so.3.0.45")),
ASCIIToUTF16("3.0.45"), ASCIIToUTF16("MyPlugin version 3.0.45"));
+static WebPluginInfo kPlugin3045r = WebPluginInfo(
+ ASCIIToUTF16("MyPlugin"), FilePath(FILE_PATH_LITERAL("myplugin.so.3.0.45")),
+ ASCIIToUTF16("3.0r45"), ASCIIToUTF16("MyPlugin version 3.0r45"));
static WebPluginInfo kPlugin4043 = WebPluginInfo(
ASCIIToUTF16("MyPlugin"), FilePath(FILE_PATH_LITERAL("myplugin.so.4.0.43")),
ASCIIToUTF16("4.0.43"), ASCIIToUTF16("MyPlugin version 4.0.43"));
@@ -84,8 +90,13 @@ TEST(PluginGroupTest, PluginGroupMatch) {
scoped_ptr<PluginGroup> group(PluginGroupTest::CreatePluginGroup(
kPluginDef3));
EXPECT_TRUE(group->Match(kPlugin3045));
+ EXPECT_TRUE(group->Match(kPlugin3045r));
+ EXPECT_FALSE(group->Match(kPluginNoVersion));
group->AddPlugin(kPlugin3045, 0);
EXPECT_FALSE(group->IsVulnerable());
+
+ group.reset(PluginGroupTest::CreatePluginGroup(kPluginDef));
+ EXPECT_FALSE(group->Match(kPluginNoVersion));
}
TEST(PluginGroupTest, PluginGroupMatchCorrectVersion) {
@@ -196,7 +207,9 @@ TEST(PluginGroupTest, VersionExtraction) {
{ "3, 0, 0, 0", "3.0.0.0" }, // Picasa
{ "1, 0, 0, 1", "1.0.0.1" }, // Earth
{ "10,0,45,2", "10.0.45.2" }, // Flash
- { "11.5.7r609", "11.5.7.609"} // Shockwave
+ { "11.5.7r609", "11.5.7.609"}, // Shockwave
+ { "10.1 r102", "10.1.102"}, // Flash
+ { "1.6.0_22", "1.6.0.22"}, // Java
};
for (size_t i = 0; i < arraysize(versions); i++) {
diff --git a/webkit/plugins/npapi/plugin_lib.h b/webkit/plugins/npapi/plugin_lib.h
index 081e593..67f5d82 100644
--- a/webkit/plugins/npapi/plugin_lib.h
+++ b/webkit/plugins/npapi/plugin_lib.h
@@ -39,6 +39,11 @@ class PluginLib : public base::RefCounted<PluginLib> {
// This API is only used on Unixes, and is exposed here for testing.
static void ParseMIMEDescription(const std::string& description,
std::vector<WebPluginMimeType>* mime_types);
+
+ // Extract a version number from a description string.
+ // This API is only used on Unixes, and is exposed here for testing.
+ static void ExtractVersionString(const std::string& version,
+ WebPluginInfo* info);
#endif
// Unloads all the loaded plugin libraries and cleans up the plugin map.
diff --git a/webkit/plugins/npapi/plugin_lib_posix.cc b/webkit/plugins/npapi/plugin_lib_posix.cc
index 19fa141..27f87de 100644
--- a/webkit/plugins/npapi/plugin_lib_posix.cc
+++ b/webkit/plugins/npapi/plugin_lib_posix.cc
@@ -185,18 +185,25 @@ bool PluginLib::ReadWebPluginInfo(const FilePath& filename,
if (NP_GetValue) {
const char* name = NULL;
NP_GetValue(NULL, nsPluginVariable_NameString, &name);
- if (name)
+ if (name) {
info->name = UTF8ToUTF16(name);
+ ExtractVersionString(name, info);
+ }
const char* description = NULL;
NP_GetValue(NULL, nsPluginVariable_DescriptionString, &description);
- if (description)
+ if (description) {
info->desc = UTF8ToUTF16(description);
+ if (info->version.empty())
+ ExtractVersionString(description, info);
+ }
LOG_IF(ERROR, PluginList::DebugPluginLoading())
<< "Got info for plugin " << filename.value()
<< " Name = \"" << UTF16ToUTF8(info->name)
- << "\", Description = \"" << UTF16ToUTF8(info->desc) << "\".";
+ << "\", Description = \"" << UTF16ToUTF8(info->desc)
+ << "\", Version = \"" << UTF16ToUTF8(info->version)
+ << "\".";
} else {
LOG_IF(ERROR, PluginList::DebugPluginLoading())
<< "Plugin " << filename.value()
@@ -252,6 +259,38 @@ void PluginLib::ParseMIMEDescription(
}
}
+// static
+void PluginLib::ExtractVersionString(const std::string& desc,
+ WebPluginInfo* info) {
+ // This matching works by extracting a version substring, along the lines of:
+ // No postfix: second match in .*<prefix>.*$
+ // With postfix: second match .*<prefix>.*<postfix>
+ static const struct {
+ const char* kPrefix;
+ const char* kPostfix;
+ } kPrePostFixes[] = {
+ { "Shockwave Flash ", 0 },
+ { "Java(TM) Plug-in ", 0 },
+ { "(using IcedTea6 ", " " },
+ { 0, 0 }
+ };
+ std::string version;
+ for (size_t i = 0; kPrePostFixes[i].kPrefix; ++i) {
+ size_t pos;
+ if ((pos = desc.find(kPrePostFixes[i].kPrefix)) != std::string::npos) {
+ version = desc.substr(pos + strlen(kPrePostFixes[i].kPrefix));
+ pos = std::string::npos;
+ if (kPrePostFixes[i].kPostfix)
+ pos = version.find(kPrePostFixes[i].kPostfix);
+ if (pos != std::string::npos)
+ version = version.substr(0, pos);
+ break;
+ }
+ }
+ if (!version.empty()) {
+ info->version = UTF8ToUTF16(version);
+ }
+}
} // namespace npapi
} // namespace webkit
diff --git a/webkit/plugins/npapi/plugin_lib_unittest.cc b/webkit/plugins/npapi/plugin_lib_unittest.cc
index 1794da90..bce68a6 100644
--- a/webkit/plugins/npapi/plugin_lib_unittest.cc
+++ b/webkit/plugins/npapi/plugin_lib_unittest.cc
@@ -152,6 +152,28 @@ TEST(MIMEDescriptionParse, ComplicatedJava) {
EXPECT_TRUE(types[4].mime_type.find(';') != std::string::npos);
}
+// Make sure we understand how to get the version numbers for common Linux
+// plug-ins.
+TEST(PluginDescriptionParse, ExtractVersion) {
+ WebPluginInfo info;
+ PluginLib::ExtractVersionString("Shockwave Flash 10.1 r102", &info);
+ EXPECT_EQ(ASCIIToUTF16("10.1 r102"), info.version);
+ PluginLib::ExtractVersionString("Java(TM) Plug-in 1.6.0_22", &info);
+ EXPECT_EQ(ASCIIToUTF16("1.6.0_22"), info.version);
+ // It's actually much more likely for a modern Linux distribution to have
+ // IcedTea.
+ PluginLib::ExtractVersionString(
+ "IcedTea NPR Web Browser Plugin "
+ "(using IcedTea6 1.9.2 (6b20-1.9.2-0ubuntu1~10.04.1))",
+ &info);
+ EXPECT_EQ(ASCIIToUTF16("1.9.2"), info.version);
+ PluginLib::ExtractVersionString(
+ "IcedTea NPR Web Browser Plugin "
+ "(using IcedTea6 1.9.3 (fedora-49.1.9.3.fc14-i386))`",
+ &info);
+ EXPECT_EQ(ASCIIToUTF16("1.9.3"), info.version);
+}
+
#endif // defined(OS_LINUX)
} // namespace npapi
diff --git a/webkit/plugins/npapi/plugin_list.cc b/webkit/plugins/npapi/plugin_list.cc
index 31a4cd6..db82d35 100644
--- a/webkit/plugins/npapi/plugin_list.cc
+++ b/webkit/plugins/npapi/plugin_list.cc
@@ -27,6 +27,18 @@ namespace npapi {
FilePath::CharType kDefaultPluginLibraryName[] =
FILE_PATH_LITERAL("default_plugin");
+// Some version ranges can be shared across operating systems. This should be
+// done where possible to avoid duplication.
+static const VersionRangeDefinition kFlashVersionRange[] = {
+ { "", "", "10.1.102" }
+};
+
+// Similarly, try and share the group definition for plug-ins that are
+// very consistent across OS'es.
+static const PluginGroupDefinition kFlashDefinition = {
+ "adobe-flash-player", "Flash", "Shockwave Flash", kFlashVersionRange,
+ arraysize(kFlashVersionRange), "http://get.adobe.com/flashplayer/" };
+
#if defined(OS_MACOSX)
// Plugin Groups for Mac.
// Plugins are listed here as soon as vulnerabilities and solutions
@@ -36,10 +48,7 @@ static const VersionRangeDefinition kQuicktimeVersionRange[] = {
{ "", "", "7.6.6" }
};
static const VersionRangeDefinition kJavaVersionRange[] = {
- { "", "", "" }
-};
-static const VersionRangeDefinition kFlashVersionRange[] = {
- { "", "", "10.1.102" }
+ { "13.0", "14.0", "13.3.0" } // Snow Leopard
};
static const VersionRangeDefinition kSilverlightVersionRange[] = {
{ "0", "4", "3.0.50106.0" },
@@ -52,13 +61,12 @@ static const VersionRangeDefinition kShockwaveVersionRange[] = {
{ "", "", "11.5.9.615" }
};
static const PluginGroupDefinition kGroupDefinitions[] = {
+ kFlashDefinition,
{ "apple-quicktime", "Quicktime", "QuickTime Plug-in", kQuicktimeVersionRange,
arraysize(kQuicktimeVersionRange),
"http://www.apple.com/quicktime/download/" },
{ "java-runtime-environment", "Java", "Java", kJavaVersionRange,
arraysize(kJavaVersionRange), "http://support.apple.com/kb/HT1338" },
- { "adobe-flash-player", "Flash", "Shockwave Flash", kFlashVersionRange,
- arraysize(kFlashVersionRange), "http://get.adobe.com/flashplayer/" },
{ "silverlight", "Silverlight", "Silverlight", kSilverlightVersionRange,
arraysize(kSilverlightVersionRange),
"http://www.microsoft.com/getsilverlight/" },
@@ -84,9 +92,6 @@ static const VersionRangeDefinition kAdobeReaderVersionRange[] = {
{ "9", "10", "9.4.1" },
{ "0", "9", "8.2.5" }
};
-static const VersionRangeDefinition kFlashVersionRange[] = {
- { "", "", "10.1.102" }
-};
static const VersionRangeDefinition kSilverlightVersionRange[] = {
{ "0", "4", "3.0.50106.0" },
{ "4", "5", "" }
@@ -98,6 +103,7 @@ static const VersionRangeDefinition kDivXVersionRange[] = {
{ "", "", "1.4.3.4" }
};
static const PluginGroupDefinition kGroupDefinitions[] = {
+ kFlashDefinition,
{ "apple-quicktime", "Quicktime", "QuickTime Plug-in", kQuicktimeVersionRange,
arraysize(kQuicktimeVersionRange),
"http://www.apple.com/quicktime/download/" },
@@ -106,8 +112,6 @@ static const PluginGroupDefinition kGroupDefinitions[] = {
{ "adobe-reader", PluginGroup::kAdobeReaderGroupName, "Adobe Acrobat",
kAdobeReaderVersionRange, arraysize(kAdobeReaderVersionRange),
"http://get.adobe.com/reader/" },
- { "adobe-flash-player", "Flash", "Shockwave Flash", kFlashVersionRange,
- arraysize(kFlashVersionRange), "http://get.adobe.com/flashplayer/" },
{ "silverlight", "Silverlight", "Silverlight", kSilverlightVersionRange,
arraysize(kSilverlightVersionRange),
"http://www.microsoft.com/getsilverlight/" },
@@ -131,7 +135,26 @@ static const PluginGroupDefinition kGroupDefinitions[] = {
};
#else
-static const PluginGroupDefinition kGroupDefinitions[] = {};
+static const VersionRangeDefinition kJavaVersionRange[] = {
+ { "0", "1.7", "1.6.0.22" }
+};
+
+static const VersionRangeDefinition kRedhatIcedTeaVersionRange[] = {
+ { "0", "1.9", "1.8.3" },
+ { "1.9", "1.10", "1.9.2" },
+};
+
+static const PluginGroupDefinition kGroupDefinitions[] = {
+ // Flash on Linux is significant because there isn't yet a built-in Flash
+ // plug-in on the Linux 64-bit version of Chrome.
+ kFlashDefinition,
+ { "java-runtime-environment", "Java 6", "Java", kJavaVersionRange,
+ arraysize(kJavaVersionRange),
+ "http://www.java.com/en/download/manual.jsp" },
+ { "redhat-icetea-java", "IcedTea", "IcedTea", kRedhatIcedTeaVersionRange,
+ arraysize(kRedhatIcedTeaVersionRange),
+ "http://www.linuxsecurity.com/content/section/3/170/" },
+};
#endif
// static