Skip to content

Commit

Permalink
Check key_creation_util_ in importer utility process
Browse files Browse the repository at this point in the history
fix brave/brave-browser#3112

Upstream commit:
commit f1ab93849fe9436e27b27ad76d59369a6ad40ce9
Author: Vasilii Sukhanov <vasilii@chromium.org>
Date:   Thu Nov 22 15:54:53 2018 +0000

    Delete kPreventEncryptionKeyOverwrites feature.

    The feature is not to be launched and the associated code is
    removed.
    The metrics collection should be running.
  • Loading branch information
darkdh authored and bbondy committed Jan 28, 2019
1 parent bf55166 commit b77d3ab
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions patches/components-os_crypt-keychain_password_mac.mm.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/components/os_crypt/keychain_password_mac.mm b/components/os_crypt/keychain_password_mac.mm
index 00fe8402c3357e08e69336752133aeb69bbc027b..0a3cf99e489abf003729e110f39bb4056d270ba5 100644
index 00fe8402c3357e08e69336752133aeb69bbc027b..a1f97f815179ee89b864b41e71f86a71ee460d8b 100644
--- a/components/os_crypt/keychain_password_mac.mm
+++ b/components/os_crypt/keychain_password_mac.mm
@@ -7,6 +7,7 @@
Expand All @@ -21,7 +21,7 @@ index 00fe8402c3357e08e69336752133aeb69bbc027b..0a3cf99e489abf003729e110f39bb405
#endif

KeychainPassword::KeychainPassword(
@@ -62,8 +63,20 @@ KeychainPassword::KeychainPassword(
@@ -62,30 +63,48 @@ KeychainPassword::KeychainPassword(
KeychainPassword::~KeychainPassword() = default;

std::string KeychainPassword::GetPassword() const {
Expand All @@ -44,14 +44,32 @@ index 00fe8402c3357e08e69336752133aeb69bbc027b..0a3cf99e489abf003729e110f39bb405
UInt32 password_length = 0;
void* password_data = NULL;
OSStatus error = keychain_.FindGenericPassword(
@@ -85,7 +98,11 @@ std::string KeychainPassword::GetPassword() const {
return password;
}
strlen(service_name), service_name, strlen(account_name), account_name,
&password_length, &password_data, NULL);

- key_creation_util_->OnKeychainLookupFailed();
+ // If we're in the importer utility process, key_creation_util_ is nullptr
+ // because it requires a PrefService and therefore can only be created in the
+ // browser process; do not dereference.
if (error == noErr) {
std::string password =
std::string(static_cast<char*>(password_data), password_length);
keychain_.ItemFreeContent(password_data);
- key_creation_util_->OnKeyWasFound();
+ if (key_creation_util_)
+ key_creation_util_->OnKeyWasFound();
return password;
}

if (error == errSecItemNotFound) {
std::string password =
AddRandomPasswordToKeychain(keychain_, service_name, account_name);
- key_creation_util_->OnKeyNotFound(!password.empty());
+ if (key_creation_util_)
+ key_creation_util_->OnKeyNotFound(!password.empty());
return password;
}

- key_creation_util_->OnKeychainLookupFailed();
+ if (key_creation_util_)
+ key_creation_util_->OnKeychainLookupFailed();
OSSTATUS_DLOG(ERROR, error) << "Keychain lookup failed";
Expand Down

0 comments on commit b77d3ab

Please sign in to comment.