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

Side by Side Diff: remoting/host/daemon_process_win.cc

Issue 2963783002: Remove unsafe registry APIs from base::win::RegKey
Patch Set: half-fix remoting Created 3 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/host/daemon_process.h" 5 #include "remoting/host/daemon_process.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 356
357 SECURITY_ATTRIBUTES security_attributes = {0}; 357 SECURITY_ATTRIBUTES security_attributes = {0};
358 security_attributes.nLength = sizeof(security_attributes); 358 security_attributes.nLength = sizeof(security_attributes);
359 security_attributes.lpSecurityDescriptor = sd.get(); 359 security_attributes.lpSecurityDescriptor = sd.get();
360 security_attributes.bInheritHandle = FALSE; 360 security_attributes.bInheritHandle = FALSE;
361 361
362 HKEY key = nullptr; 362 HKEY key = nullptr;
363 result = ::RegCreateKeyEx( 363 result = ::RegCreateKeyEx(
364 root.Handle(), kPairingRegistrySecretsKeyName, 0, nullptr, 0, 364 root.Handle(), kPairingRegistrySecretsKeyName, 0, nullptr, 0,
365 KEY_READ | KEY_WRITE, &security_attributes, &key, &disposition); 365 KEY_READ | KEY_WRITE, &security_attributes, &key, &disposition);
366 privileged.Set(key); 366 if (result == ERROR_SUCCESS) {
367 RegCloseKey(key);
368 privileged.Open(root.Handle(), kPairingRegistrySecretsKeyName,
369 KEY_READ | KEY_WRITE);
370 }
367 } 371 }
368 372
369 if (result != ERROR_SUCCESS) { 373 if (result != ERROR_SUCCESS) {
370 ::SetLastError(result); 374 ::SetLastError(result);
371 PLOG(ERROR) << "Failed to open or create HKLM\\" << kPairingRegistryKeyName 375 PLOG(ERROR) << "Failed to open or create HKLM\\" << kPairingRegistryKeyName
372 << "\\" << kPairingRegistrySecretsKeyName; 376 << "\\" << kPairingRegistrySecretsKeyName;
373 return false; 377 return false;
374 } 378 }
375 379
376 pairing_registry_privileged_key_.Set(privileged.Take()); 380 pairing_registry_privileged_key_ = std::move(privileged);
377 pairing_registry_unprivileged_key_.Set(unprivileged.Take()); 381 pairing_registry_unprivileged_key_ = std::move(unprivileged);
378 return true; 382 return true;
379 } 383 }
380 384
381 } // namespace remoting 385 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698