diff options
author | krstnmnlsn@chromium.org <krstnmnlsn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-27 19:27:07 +0000 |
---|---|---|
committer | krstnmnlsn@chromium.org <krstnmnlsn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-27 19:27:07 +0000 |
commit | 1c2bbf47bd5c796939967934f23862b2ef5a4814 (patch) | |
tree | 3c62b5b7bc8e3c7c8f79b1d40c9307aa1507fad0 /chrome_elf | |
parent | b3313b71eb51e5fc5e83343e437c86b98c49be54 (diff) | |
download | chromium_src-1c2bbf47bd5c796939967934f23862b2ef5a4814.zip chromium_src-1c2bbf47bd5c796939967934f23862b2ef5a4814.tar.gz chromium_src-1c2bbf47bd5c796939967934f23862b2ef5a4814.tar.bz2 |
Adding blacklisted dlls to safe browsing incident reports.
Also added a unit test to environment_data_collection_win_unittest.cc
Edited chrome_elf_init_win.cc and blacklist.cc so that the registry is
only cleared immediately before being repopulated (and safe browsing is not left
with an empty registry to read from).
BUG=
Review URL: https://codereview.chromium.org/346763003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280380 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_elf')
-rw-r--r-- | chrome_elf/blacklist/blacklist.cc | 21 | ||||
-rw-r--r-- | chrome_elf/blacklist/blacklist.h | 2 | ||||
-rw-r--r-- | chrome_elf/blacklist/test/blacklist_test.cc | 4 |
3 files changed, 13 insertions, 14 deletions
diff --git a/chrome_elf/blacklist/blacklist.cc b/chrome_elf/blacklist/blacklist.cc index 46f06975..55afb87 100644 --- a/chrome_elf/blacklist/blacklist.cc +++ b/chrome_elf/blacklist/blacklist.cc @@ -386,7 +386,7 @@ bool Initialize(bool force) { return NT_SUCCESS(ret) && page_executable; } -bool AddDllsFromRegistryToBlacklist() { +void AddDllsFromRegistryToBlacklist() { HKEY key = NULL; LONG result = ::RegOpenKeyEx(HKEY_CURRENT_USER, kRegistryFinchListPath, @@ -395,9 +395,9 @@ bool AddDllsFromRegistryToBlacklist() { &key); if (result != ERROR_SUCCESS) - return false; + return; - // We add dlls from the registry to the blacklist, and then clear registry. + // We add dlls from the registry to the blacklist. DWORD value_len; DWORD name_len = MAX_PATH; std::vector<wchar_t> name_buffer(name_len); @@ -406,24 +406,23 @@ bool AddDllsFromRegistryToBlacklist() { value_len = 0; result = ::RegEnumValue( key, i, &name_buffer[0], &name_len, NULL, NULL, NULL, &value_len); + if (result != ERROR_SUCCESS) + break; + name_len = name_len + 1; value_len = value_len + 1; std::vector<wchar_t> value_buffer(value_len); result = ::RegEnumValue(key, i, &name_buffer[0], &name_len, NULL, NULL, reinterpret_cast<BYTE*>(&value_buffer[0]), &value_len); + if (result != ERROR_SUCCESS) + break; value_buffer[value_len - 1] = L'\0'; - - if (result == ERROR_SUCCESS) { - AddDllToBlacklist(&value_buffer[0]); - } + AddDllToBlacklist(&value_buffer[0]); } - // Delete the finch registry key to clear the values. - result = ::RegDeleteKey(key, L""); - ::RegCloseKey(key); - return result == ERROR_SUCCESS; + return; } } // namespace blacklist diff --git a/chrome_elf/blacklist/blacklist.h b/chrome_elf/blacklist/blacklist.h index 58cc16b..9ea680c 100644 --- a/chrome_elf/blacklist/blacklist.h +++ b/chrome_elf/blacklist/blacklist.h @@ -62,7 +62,7 @@ extern "C" void SuccessfullyBlocked(const wchar_t** blocked_dlls, int* size); // Add the dlls, originally passed in through finch, from the registry to the // blacklist so that they will be blocked identically to those hard coded in. -extern "C" bool AddDllsFromRegistryToBlacklist(); +extern "C" void AddDllsFromRegistryToBlacklist(); // Record that the dll at the given index was blocked. void BlockedDll(size_t blocked_index); diff --git a/chrome_elf/blacklist/test/blacklist_test.cc b/chrome_elf/blacklist/test/blacklist_test.cc index 2e3f9a4..4f9859d 100644 --- a/chrome_elf/blacklist/test/blacklist_test.cc +++ b/chrome_elf/blacklist/test/blacklist_test.cc @@ -32,7 +32,7 @@ extern "C" { // When modifying the blacklist in the test process, use the exported test dll // functions on the test blacklist dll, not the ones linked into the test // executable itself. -__declspec(dllimport) bool TestDll_AddDllsFromRegistryToBlacklist(); +__declspec(dllimport) void TestDll_AddDllsFromRegistryToBlacklist(); __declspec(dllimport) bool TestDll_AddDllToBlacklist(const wchar_t* dll_name); __declspec(dllimport) bool TestDll_IsBlacklistInitialized(); __declspec(dllimport) bool TestDll_RemoveDllFromBlacklist( @@ -240,7 +240,7 @@ TEST_F(BlacklistTest, AddDllsFromRegistryToBlacklist) { test_data[i].dll_name); } - EXPECT_TRUE(TestDll_AddDllsFromRegistryToBlacklist()); + TestDll_AddDllsFromRegistryToBlacklist(); CheckBlacklistedDllsNotLoaded(); } |