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

Unified Diff: chrome/common/extensions/extension_resource_unittest.cc

Issue 11308204: Fix directory traversal in extension_resources.cc. Adds test case, which is complicated by several… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/extension_resource.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/extension_resource_unittest.cc
===================================================================
--- chrome/common/extensions/extension_resource_unittest.cc (revision 169455)
+++ chrome/common/extensions/extension_resource_unittest.cc (working copy)
@@ -49,6 +49,8 @@
FilePath inner_dir = temp.path().AppendASCII("directory");
ASSERT_TRUE(file_util::CreateDirectory(inner_dir));
+ FilePath sub_dir = inner_dir.AppendASCII("subdir");
+ ASSERT_TRUE(file_util::CreateDirectory(sub_dir));
FilePath inner_file = inner_dir.AppendASCII("inner");
FilePath outer_file = temp.path().AppendASCII("outer");
ASSERT_TRUE(file_util::WriteFile(outer_file, "X", 1));
@@ -86,6 +88,16 @@
r4.set_follow_symlinks_anywhere();
EXPECT_TRUE(r4.GetFilePath().empty());
+ // ... and not even when clever current-directory syntax is present. Note
+ // that the path for this test case can't start with the current directory
+ // component due to quirks in FilePath::Append(), and the path must exist.
+ ExtensionResource r4a(
+ extension_id, inner_dir,
+ FilePath().AppendASCII("subdir").AppendASCII(".").AppendASCII("..").
+ AppendASCII("..").AppendASCII("outer"));
+ r4a.set_follow_symlinks_anywhere();
+ EXPECT_TRUE(r4a.GetFilePath().empty());
+
#if defined(OS_POSIX)
// The non-packing extension should also not be able to access a resource that
// symlinks out of the directory.
« no previous file with comments | « chrome/common/extensions/extension_resource.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698