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

Side by Side Diff: chrome_elf/blacklist/blacklist.cc

Issue 678193003: Fix two minor bugs found by /analyze (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 DWORD blacklist_state = BLACKLIST_STATE_MAX; 151 DWORD blacklist_state = BLACKLIST_STATE_MAX;
152 DWORD blacklist_state_size = sizeof(blacklist_state); 152 DWORD blacklist_state_size = sizeof(blacklist_state);
153 DWORD type = 0; 153 DWORD type = 0;
154 result = ::RegQueryValueEx(key, 154 result = ::RegQueryValueEx(key,
155 kBeaconState, 155 kBeaconState,
156 0, 156 0,
157 &type, 157 &type,
158 reinterpret_cast<LPBYTE>(&blacklist_state), 158 reinterpret_cast<LPBYTE>(&blacklist_state),
159 &blacklist_state_size); 159 &blacklist_state_size);
160 160
161 if (blacklist_state == BLACKLIST_DISABLED || result != ERROR_SUCCESS || 161 if (result != ERROR_SUCCESS || blacklist_state == BLACKLIST_DISABLED ||
162 type != REG_DWORD) { 162 type != REG_DWORD) {
163 ::RegCloseKey(key); 163 ::RegCloseKey(key);
164 return false; 164 return false;
165 } 165 }
166 166
167 if (!GenerateStateFromBeaconAndAttemptCount(&key, blacklist_state)) { 167 if (!GenerateStateFromBeaconAndAttemptCount(&key, blacklist_state)) {
168 ::RegCloseKey(key); 168 ::RegCloseKey(key);
169 return false; 169 return false;
170 } 170 }
171 171
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 while (blacklist::g_troublesome_dlls[++size] != NULL) {} 220 while (blacklist::g_troublesome_dlls[++size] != NULL) {}
221 221
222 return size; 222 return size;
223 } 223 }
224 224
225 bool IsBlacklistInitialized() { 225 bool IsBlacklistInitialized() {
226 return g_blacklist_initialized; 226 return g_blacklist_initialized;
227 } 227 }
228 228
229 int GetBlacklistIndex(const wchar_t* dll_name) { 229 int GetBlacklistIndex(const wchar_t* dll_name) {
230 for (int i = 0; i < kTroublesomeDllsMaxCount, g_troublesome_dlls[i]; ++i) { 230 for (int i = 0; i < kTroublesomeDllsMaxCount && g_troublesome_dlls[i]; ++i) {
231 if (_wcsicmp(dll_name, g_troublesome_dlls[i]) == 0) 231 if (_wcsicmp(dll_name, g_troublesome_dlls[i]) == 0)
232 return i; 232 return i;
233 } 233 }
234 return -1; 234 return -1;
235 } 235 }
236 236
237 bool AddDllToBlacklist(const wchar_t* dll_name) { 237 bool AddDllToBlacklist(const wchar_t* dll_name) {
238 int blacklist_size = BlacklistSize(); 238 int blacklist_size = BlacklistSize();
239 // We need to leave one space at the end for the null pointer. 239 // We need to leave one space at the end for the null pointer.
240 if (blacklist_size + 1 >= kTroublesomeDllsMaxCount) 240 if (blacklist_size + 1 >= kTroublesomeDllsMaxCount)
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 break; 431 break;
432 value_buffer[value_len - 1] = L'\0'; 432 value_buffer[value_len - 1] = L'\0';
433 AddDllToBlacklist(&value_buffer[0]); 433 AddDllToBlacklist(&value_buffer[0]);
434 } 434 }
435 435
436 ::RegCloseKey(key); 436 ::RegCloseKey(key);
437 return; 437 return;
438 } 438 }
439 439
440 } // namespace blacklist 440 } // namespace blacklist
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698