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

Unified Diff: chrome_elf/blacklist/blacklist.cc

Issue 138903022: Cleanup browser blacklist code (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 11 months 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
Index: chrome_elf/blacklist/blacklist.cc
diff --git a/chrome_elf/blacklist/blacklist.cc b/chrome_elf/blacklist/blacklist.cc
index eda611db41eba3a80f35c9f15964aaaa1c6bf47e..6a4e942cf431f73836b85c83171f119bf2af367f 100644
--- a/chrome_elf/blacklist/blacklist.cc
+++ b/chrome_elf/blacklist/blacklist.cc
@@ -19,8 +19,11 @@ extern "C" IMAGE_DOS_HEADER __ImageBase;
namespace blacklist{
-const wchar_t* g_troublesome_dlls[kTroublesomeDllsMaxCount] = {};
-int g_troublesome_dlls_cur_index = 0;
+const wchar_t* g_troublesome_dlls[kTroublesomeDllsMaxCount] = {
+ L"libsvn_tsvn32.dll",
+ // Keep this null pointer here to mark the end of the list.
+ NULL,
+};
const wchar_t kRegistryBeaconPath[] = L"SOFTWARE\\Google\\Chrome\\BLBeacon";
const wchar_t kBeaconVersion[] = L"version";
@@ -233,11 +236,22 @@ bool ResetBeacon() {
return (result == ERROR_SUCCESS);
}
+int BlacklistSize() {
+ int size = 0;
+ while(blacklist::g_troublesome_dlls[size] != NULL) {
+ ++size;
+ }
robertshield 2014/01/24 01:50:24 nit: no brackets needed for one line body. also sp
csharp 2014/01/24 16:22:59 Removed unneeded brackets. The function needs to
+
+ return size;
+}
+
bool AddDllToBlacklist(const wchar_t* dll_name) {
- if (g_troublesome_dlls_cur_index >= kTroublesomeDllsMaxCount)
+ int blacklist_size = BlacklistSize();
+ // We need to leave one space at the end for the null pointer.
+ if (blacklist_size + 1 >= kTroublesomeDllsMaxCount)
return false;
- for (int i = 0; i < g_troublesome_dlls_cur_index; ++i) {
- if (!wcscmp(g_troublesome_dlls[i], dll_name))
+ for (int i=0; i < blacklist_size; ++i) {
+ if (!_wcsicmp(g_troublesome_dlls[i], dll_name))
return true;
}
@@ -245,20 +259,19 @@ bool AddDllToBlacklist(const wchar_t* dll_name) {
wchar_t* str_buffer = new wchar_t[wcslen(dll_name) + 1];
wcscpy(str_buffer, dll_name);
- g_troublesome_dlls[g_troublesome_dlls_cur_index] = str_buffer;
- g_troublesome_dlls_cur_index++;
+ g_troublesome_dlls[blacklist_size] = str_buffer;
return true;
}
bool RemoveDllFromBlacklist(const wchar_t* dll_name) {
- for (int i = 0; i < g_troublesome_dlls_cur_index; ++i) {
- if (!wcscmp(g_troublesome_dlls[i], dll_name)) {
+ int blacklist_size = BlacklistSize();
+ for (int i = 0; i < blacklist_size; ++i) {
+ if (!_wcsicmp(g_troublesome_dlls[i], dll_name)) {
// Found the thing to remove. Delete it then replace it with the last
// element.
- g_troublesome_dlls_cur_index--;
delete[] g_troublesome_dlls[i];
- g_troublesome_dlls[i] = g_troublesome_dlls[g_troublesome_dlls_cur_index];
- g_troublesome_dlls[g_troublesome_dlls_cur_index] = NULL;
+ g_troublesome_dlls[i] = g_troublesome_dlls[blacklist_size - 1];
+ g_troublesome_dlls[blacklist_size - 1] = NULL;
return true;
}
}

Powered by Google App Engine
This is Rietveld 408576698