Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: return boolean from
safeStorage.isEncryptionAvailable()
instea…
…d of crashing On Linux, `isEncryptionAvailable()` was crashing instead of returning a boolean before the 'ready' event was emitted by the app. The reason of the crash is that [`CreateKeyStorage()`](https://source.chromium.org/chromium/chromium/src/+/main:components/os_crypt/os_crypt_linux.cc;l=74;drc=35be6215ec8f09e50176f36753c68f26c63d1885;bpv=1;bpt=0) expects the config to be set but the function responsible for setting the config, [`SetConfig()`](https://source.chromium.org/chromium/chromium/src/+/main:components/os_crypt/os_crypt_linux.cc;l=237;drc=35be6215ec8f09e50176f36753c68f26c63d1885;bpv=1;bpt=0), is called only after the app is ready inside [`PostCreateMainMessageLoop()`](https://github.com/electron/electron/blob/main/shell/browser/electron_browser_main_parts.cc#L499). So this change patches [`IsEncryptionAvailable()`](https://source.chromium.org/chromium/chromium/src/+/main:components/os_crypt/os_crypt_linux.cc;l=245;drc=35be6215ec8f09e50176f36753c68f26c63d1885;bpv=1;bpt=0) to return false if the config hasn't been set already. Fixes: #32206 Signed-off-by: Darshan Sen <raisinten@gmail.com>
- Loading branch information
Showing
4 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...omium/fix_return_boolean_from_safestorage_isencryptionavailable_instead_of_crashing.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Darshan Sen <raisinten@gmail.com> | ||
Date: Mon, 25 Apr 2022 17:03:34 +0530 | ||
Subject: fix: return boolean from `safeStorage.isEncryptionAvailable()` instead of crashing | ||
|
||
On Linux, `isEncryptionAvailable()` was crashing instead of returning a | ||
boolean before the 'ready' event was emitted by the app. The reason of | ||
the crash is that [`CreateKeyStorage()`](https://source.chromium.org/chromium/chromium/src/+/main:components/os_crypt/os_crypt_linux.cc;l=74;drc=35be6215ec8f09e50176f36753c68f26c63d1885;bpv=1;bpt=0) | ||
expects the config to be set but the function responsible for setting the | ||
config, [`SetConfig()`](https://source.chromium.org/chromium/chromium/src/+/main:components/os_crypt/os_crypt_linux.cc;l=237;drc=35be6215ec8f09e50176f36753c68f26c63d1885;bpv=1;bpt=0), | ||
is called only after the app is ready inside [`PostCreateMainMessageLoop()`](https://github.com/electron/electron/blob/main/shell/browser/electron_browser_main_parts.cc#L499). | ||
So this change patches [`IsEncryptionAvailable()`](https://source.chromium.org/chromium/chromium/src/+/main:components/os_crypt/os_crypt_linux.cc;l=245;drc=35be6215ec8f09e50176f36753c68f26c63d1885;bpv=1;bpt=0) | ||
to return false if the config hasn't been set already. | ||
|
||
Fixes: https://github.com/electron/electron/issues/32206 | ||
Signed-off-by: Darshan Sen <raisinten@gmail.com> | ||
|
||
diff --git a/os_crypt/os_crypt_linux.cc b/os_crypt/os_crypt_linux.cc | ||
index 07da4e55f1788..2781d060bbe1d 100644 | ||
--- a/os_crypt/os_crypt_linux.cc | ||
+++ b/os_crypt/os_crypt_linux.cc | ||
@@ -242,7 +242,7 @@ void OSCrypt::SetConfig(std::unique_ptr<os_crypt::Config> config) { | ||
|
||
// static | ||
bool OSCrypt::IsEncryptionAvailable() { | ||
- return g_get_password[Version::V11](); | ||
+ return g_cache.Get().config && g_get_password[Version::V11](); | ||
} | ||
|
||
// static |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters