OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome_elf/blacklist/blacklist.h" | 5 #include "chrome_elf/blacklist/blacklist.h" |
6 | 6 |
7 #include <assert.h> | 7 #include <assert.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 while (blacklist::g_troublesome_dlls[++size] != NULL) {} | 236 while (blacklist::g_troublesome_dlls[++size] != NULL) {} |
237 | 237 |
238 return size; | 238 return size; |
239 } | 239 } |
240 | 240 |
241 bool IsBlacklistInitialized() { | 241 bool IsBlacklistInitialized() { |
242 return g_blacklist_initialized; | 242 return g_blacklist_initialized; |
243 } | 243 } |
244 | 244 |
245 int GetBlacklistIndex(const wchar_t* dll_name) { | 245 int GetBlacklistIndex(const wchar_t* dll_name) { |
246 for (int i = 0; i < kTroublesomeDllsMaxCount && g_troublesome_dlls[i]; ++i) { | 246 for (int i = 0; |
| 247 i < static_cast<int>(kTroublesomeDllsMaxCount) && g_troublesome_dlls[i]; |
| 248 ++i) { |
247 if (_wcsicmp(dll_name, g_troublesome_dlls[i]) == 0) | 249 if (_wcsicmp(dll_name, g_troublesome_dlls[i]) == 0) |
248 return i; | 250 return i; |
249 } | 251 } |
250 return -1; | 252 return -1; |
251 } | 253 } |
252 | 254 |
253 bool AddDllToBlacklist(const wchar_t* dll_name) { | 255 bool AddDllToBlacklist(const wchar_t* dll_name) { |
254 int blacklist_size = BlacklistSize(); | 256 int blacklist_size = BlacklistSize(); |
255 // We need to leave one space at the end for the null pointer. | 257 // We need to leave one space at the end for the null pointer. |
256 if (blacklist_size + 1 >= kTroublesomeDllsMaxCount) | 258 if (blacklist_size + 1 >= static_cast<int>(kTroublesomeDllsMaxCount)) |
257 return false; | 259 return false; |
258 for (int i = 0; i < blacklist_size; ++i) { | 260 for (int i = 0; i < blacklist_size; ++i) { |
259 if (!_wcsicmp(g_troublesome_dlls[i], dll_name)) | 261 if (!_wcsicmp(g_troublesome_dlls[i], dll_name)) |
260 return true; | 262 return true; |
261 } | 263 } |
262 | 264 |
263 // Copy string to blacklist. | 265 // Copy string to blacklist. |
264 wchar_t* str_buffer = new wchar_t[wcslen(dll_name) + 1]; | 266 wchar_t* str_buffer = new wchar_t[wcslen(dll_name) + 1]; |
265 wcscpy(str_buffer, dll_name); | 267 wcscpy(str_buffer, dll_name); |
266 | 268 |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 break; | 449 break; |
448 value_buffer[value_len - 1] = L'\0'; | 450 value_buffer[value_len - 1] = L'\0'; |
449 AddDllToBlacklist(&value_buffer[0]); | 451 AddDllToBlacklist(&value_buffer[0]); |
450 } | 452 } |
451 | 453 |
452 ::RegCloseKey(key); | 454 ::RegCloseKey(key); |
453 return; | 455 return; |
454 } | 456 } |
455 | 457 |
456 } // namespace blacklist | 458 } // namespace blacklist |
OLD | NEW |