diff options
author | tommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-10 01:32:57 +0000 |
---|---|---|
committer | tommycli@chromium.org <tommycli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-10 01:32:57 +0000 |
commit | 9deeb3fc56f5271fce654ca06618a044d295c490 (patch) | |
tree | f22dadb50b72114ab6a4557fb1e903c4594ed0d5 /chrome/utility | |
parent | 01f32e4743e8146273bc26bf5e87deea46896686 (diff) | |
download | chromium_src-9deeb3fc56f5271fce654ca06618a044d295c490.zip chromium_src-9deeb3fc56f5271fce654ca06618a044d295c490.tar.gz chromium_src-9deeb3fc56f5271fce654ca06618a044d295c490.tar.bz2 |
Media Galleries API Picasa: Put PMP parsing step into sandboxed utility process.
This changeset moves the Picasa PMP database parsing step onto the sandboxed utility process to securify the parsing of untrusted user data.
The CL is contingent on 18231002.
BUG=151701
Review URL: https://chromiumcodereview.appspot.com/18387003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210701 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/utility')
-rw-r--r-- | chrome/utility/chrome_content_utility_client.cc | 31 | ||||
-rw-r--r-- | chrome/utility/chrome_content_utility_client.h | 7 | ||||
-rw-r--r-- | chrome/utility/media_galleries/picasa_album_table_reader_unittest.cc | 27 |
3 files changed, 39 insertions, 26 deletions
diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc index 132cbed..a3d7b8f 100644 --- a/chrome/utility/chrome_content_utility_client.cc +++ b/chrome/utility/chrome_content_utility_client.cc @@ -42,7 +42,9 @@ #endif // defined(OS_WIN) #if defined(OS_WIN) || defined(OS_MACOSX) +#include "chrome/common/media_galleries/picasa_types.h" #include "chrome/utility/itunes_library_parser.h" +#include "chrome/utility/media_galleries/picasa_album_table_reader.h" #endif // defined(OS_WIN) || defined(OS_MACOSX) #if defined(ENABLE_PRINTING) @@ -125,6 +127,8 @@ bool ChromeContentUtilityClient::OnMessageReceived( #if defined(OS_WIN) || defined(OS_MACOSX) IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesLibraryXmlFile, OnParseITunesLibraryXmlFile) + IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParsePicasaPMPDatabase, + OnParsePicasaPMPDatabase) #endif // defined(OS_WIN) || defined(OS_MACOSX) IPC_MESSAGE_UNHANDLED(handled = false) @@ -516,6 +520,33 @@ void ChromeContentUtilityClient::OnParseITunesLibraryXmlFile( Send(new ChromeUtilityHostMsg_GotITunesLibrary(result, parser.library())); ReleaseProcessIfNeeded(); } + +void ChromeContentUtilityClient::OnParsePicasaPMPDatabase( + const picasa::AlbumTableFilesForTransit& album_table_files) { + picasa::AlbumTableFiles files; + files.indicator_file = IPC::PlatformFileForTransitToPlatformFile( + album_table_files.indicator_file); + files.category_file = IPC::PlatformFileForTransitToPlatformFile( + album_table_files.category_file); + files.date_file = IPC::PlatformFileForTransitToPlatformFile( + album_table_files.date_file); + files.filename_file = IPC::PlatformFileForTransitToPlatformFile( + album_table_files.filename_file); + files.name_file = IPC::PlatformFileForTransitToPlatformFile( + album_table_files.name_file); + files.token_file = IPC::PlatformFileForTransitToPlatformFile( + album_table_files.token_file); + files.uid_file = IPC::PlatformFileForTransitToPlatformFile( + album_table_files.uid_file); + + picasa::PicasaAlbumTableReader reader(files); + bool parse_success = reader.Init(); + Send(new ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished( + parse_success, + reader.albums(), + reader.folders())); + ReleaseProcessIfNeeded(); +} #endif // defined(OS_WIN) || defined(OS_MACOSX) } // namespace chrome diff --git a/chrome/utility/chrome_content_utility_client.h b/chrome/utility/chrome_content_utility_client.h index 93896d0..a6ebcfe 100644 --- a/chrome/utility/chrome_content_utility_client.h +++ b/chrome/utility/chrome_content_utility_client.h @@ -21,6 +21,10 @@ namespace gfx { class Rect; } +namespace picasa { +struct AlbumTableFilesForTransit; +} + namespace printing { struct PageRange; } @@ -85,6 +89,9 @@ class ChromeContentUtilityClient : public content::ContentUtilityClient { #endif // defined(OS_WIN) #if defined(OS_WIN) || defined(OS_MACOSX) + void OnParsePicasaPMPDatabase( + const picasa::AlbumTableFilesForTransit& album_table_files); + void OnParseITunesLibraryXmlFile( IPC::PlatformFileForTransit itunes_library_file); #endif // defined(OS_WIN) || defined(OS_MACOSX) diff --git a/chrome/utility/media_galleries/picasa_album_table_reader_unittest.cc b/chrome/utility/media_galleries/picasa_album_table_reader_unittest.cc index d9980b9..3c5991c 100644 --- a/chrome/utility/media_galleries/picasa_album_table_reader_unittest.cc +++ b/chrome/utility/media_galleries/picasa_album_table_reader_unittest.cc @@ -11,30 +11,6 @@ namespace picasa { namespace { -base::PlatformFile OpenPlatformFile(const base::FilePath& directory_path, - const std::string& suffix) { - base::FilePath path = directory_path.Append(base::FilePath::FromUTF8Unsafe( - std::string(kPicasaAlbumTableName) + "_" + suffix)); - int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; - return base::CreatePlatformFile(path, flags, NULL, NULL); -} - -base::PlatformFile OpenColumnPlatformFile(const base::FilePath& directory_path, - const std::string& column_name) { - return OpenPlatformFile(directory_path, column_name + "." + kPmpExtension); -} - -AlbumTableFiles MakeAlbumTableFiles(const base::FilePath& directory_path) { - AlbumTableFiles files; - files.indicator_file = OpenPlatformFile(directory_path, "0"); - files.category_file = OpenColumnPlatformFile(directory_path, "category"); - files.date_file = OpenColumnPlatformFile(directory_path, "date"); - files.filename_file = OpenColumnPlatformFile(directory_path, "filename"); - files.name_file = OpenColumnPlatformFile(directory_path, "name"); - files.token_file = OpenColumnPlatformFile(directory_path, "token"); - files.uid_file = OpenColumnPlatformFile(directory_path, "uid"); -} - TEST(PicasaAlbumTableReaderTest, FoldersAndAlbums) { PmpTestHelper test_helper(kPicasaAlbumTableName); ASSERT_TRUE(test_helper.Init()); @@ -89,8 +65,7 @@ TEST(PicasaAlbumTableReaderTest, FoldersAndAlbums) { ASSERT_TRUE(test_helper.WriteColumnFileFromVector( "uid", PMP_TYPE_STRING, uid_vector)); - AlbumTableFiles album_table_files = - MakeAlbumTableFiles(test_helper.GetTempDirPath()); + AlbumTableFiles album_table_files(test_helper.GetTempDirPath()); PicasaAlbumTableReader reader(album_table_files); ASSERT_TRUE(reader.Init()); |