KEMBAR78
fix: crash in `safeStorage` on Linux by RaisinTen · Pull Request #34263 · electron/electron · GitHub
Skip to content

Conversation

@RaisinTen
Copy link
Contributor

Backport of #33913.

See that PR for details.

Notes: none.

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 changes `IsEncryptionAvailable()` to return `false` when the app
is not ready on Linux and uses that instead of the raw API in other
places like `EncryptString()` and `DecryptString()`.

Fixes: electron#32206
Signed-off-by: Darshan Sen <raisinten@gmail.com>
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label May 17, 2022
@trop trop bot mentioned this pull request May 17, 2022
5 tasks
@trop trop bot added 15-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes labels May 17, 2022
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label May 17, 2022
Signed-off-by: Darshan Sen <raisinten@gmail.com>
Copy link
Member

@jkleinsc jkleinsc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newly added tests are failing.

RaisinTen added 2 commits May 18, 2022 11:51
This backports electron@0e09738.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
network::mojom::NetworkService::SetEncryptionKey() is only available on
Windows and macOS.

Signed-off-by: Darshan Sen <raisinten@gmail.com>
@RaisinTen RaisinTen requested a review from jkleinsc May 18, 2022 10:09
@RaisinTen
Copy link
Contributor Author

@jkleinsc the newly added tests are passing now.

@codebytere codebytere changed the title fix: fix a crash in safeStorage on Linux fix: crash in safeStorage on Linux May 18, 2022
@codebytere codebytere dismissed jkleinsc’s stale review May 19, 2022 08:04

Tests are now passing :)

@codebytere codebytere merged commit d5ba5c8 into electron:15-x-y May 19, 2022
@release-clerk
Copy link

release-clerk bot commented May 19, 2022

No Release Notes

@RaisinTen RaisinTen deleted the 15-bp-safeStorage-linux-crash branch May 19, 2022 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

15-x-y backport This is a backport PR semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants