diff options
author | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-23 17:42:48 +0000 |
---|---|---|
committer | scherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-23 17:42:48 +0000 |
commit | ad236677881a30936a7d78607a98702bb40332e1 (patch) | |
tree | 6213e6a5febf58bd5444cc32ac88629c3f37b8ad /media/base | |
parent | 23f01c4e3d688bf2f5bf798a31ec2ce30fa6b8b3 (diff) | |
download | chromium_src-ad236677881a30936a7d78607a98702bb40332e1.zip chromium_src-ad236677881a30936a7d78607a98702bb40332e1.tar.gz chromium_src-ad236677881a30936a7d78607a98702bb40332e1.tar.bz2 |
Limit the DLL search path when loading FFmpeg binaries on Windows.
This prevents us from accidentally loading other copies of FFmpeg during renderer process boot.
BUG=35857
TEST=install a real version of chrome (don't simply unzip a build). close chrome. create an empty file named C:\Windows\avutil-50.dll. start chrome and go to www.youtube.com/html5. no error dialog box should appear. repeat these steps with an earlier version of chrome to verify that an error dialog box appears complaining about C:\Windows\avutil-50.dll.
Review URL: http://codereview.chromium.org/2856013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50617 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base')
-rw-r--r-- | media/base/media_win.cc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/media/base/media_win.cc b/media/base/media_win.cc index e4d67f5..b0357f7 100644 --- a/media/base/media_win.cc +++ b/media/base/media_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,6 +9,7 @@ #include "base/file_path.h" #include "base/logging.h" #include "base/path_service.h" +#include "base/scoped_ptr.h" // Enable timing code by turning on TESTING macro. //#define TESTING 1 @@ -64,8 +65,17 @@ bool InitializeMediaLibrary(const FilePath& base_path) { media::FILE_LIBAVUTIL }; HMODULE libs[arraysize(path_keys)] = {NULL}; + + // Limit the DLL search path so we don't load dependencies from the system + // path. Refer to http://crbug.com/35857 + scoped_array<wchar_t> previous_dll_directory(new wchar_t[MAX_PATH]); + if (!GetDllDirectory(MAX_PATH, previous_dll_directory.get())) { + previous_dll_directory.reset(); + } + SetDllDirectory(base_path.value().c_str()); + for (size_t i = 0; i < arraysize(path_keys); ++i) { - FilePath path = base_path.Append(GetDLLName(path_keys[i])); + FilePath path(GetDLLName(path_keys[i])); #ifdef TESTING double dll_loadtime_start = GetTime(); #endif @@ -82,6 +92,8 @@ bool InitializeMediaLibrary(const FilePath& base_path) { #endif } + SetDllDirectory(previous_dll_directory.get()); + // Check that we loaded all libraries successfully. We only need to check the // last array element because the loop above will break without initializing // it on any prior error. |