Files
electron/patches/node/src_account_for_openssl_unexpected_version.patch
electron-roller[bot] b3d52c01e8 chore: bump node to v20.16.0 (main) (#43029)
* chore: bump node in DEPS to v20.16.0

* test: skip unstable shadow realm gc tests

https://github.com/nodejs/node/pull/52855

* test: extend env for `test-node-output-errors`

https://github.com/nodejs/node/pull/53535

* src: fix typo in env.cc

https://github.com/nodejs/node/pull/53418

* src: reset `process.versions` during pre-execution

https://github.com/nodejs/node/pull/53444

* chore: fixup patch indices

* src,permission: --allow-wasi & prevent WASI exec

https://github.com/nodejs/node/pull/53124

* tls: use SSL_get_peer_tmp_key

https://github.com/nodejs/node/pull/53366

* deps: update c-ares to 1.29.0

https://github.com/nodejs/node/pull/53155

* src: account for OpenSSL unexpected version

* crypto: fix propagation of "memory limit exceeded"

https://github.com/nodejs/node/pull/53300

* process: add process.getBuiltinModule(id)

https://github.com/nodejs/node/pull/52762

* windows 32bit: config change callback needs to be stdcall

8f265c9d51

* fix: building with UNICODE

https://github.com/c-ares/c-ares/pull/802

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
2024-07-26 12:52:05 -04:00

46 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu, 25 Jul 2024 12:19:41 +0200
Subject: src: account for OpenSSL unexpected version
Fixes a crash that occurs because the logic to parse for an OpenSSL
version didn't account for OpenSSL_version returning a value that
doesn't match the expected pattern of OpenSSL 1.1.0i 14 Aug 2018.
In Electron's case, OpenSSL_version returns just BoringSSL, which in
combination with the search logic not accounting for the delimiter not
being present caused an out-of-bounds crash:
out_of_range was thrown in -fno-exceptions mode with message "basic_string"
This fixes that by checking for the null terminator and returning 0.0.0
when the target delimiter isn't present.
Upstreamed at https://github.com/nodejs/node/pull/54038
diff --git a/src/node_metadata.cc b/src/node_metadata.cc
index 985d44b3cd1f1aa5c09f99e868083f2e48c7e32b..1876249eb88065f649aee2c8348f42ec90ab70da 100644
--- a/src/node_metadata.cc
+++ b/src/node_metadata.cc
@@ -48,14 +48,19 @@ Metadata metadata;
#if HAVE_OPENSSL
static constexpr size_t search(const char* s, char c, size_t n = 0) {
- return *s == c ? n : search(s + 1, c, n + 1);
+ return *s == '\0' ? n : (*s == c ? n : search(s + 1, c, n + 1));
}
static inline std::string GetOpenSSLVersion() {
// sample openssl version string format
// for reference: "OpenSSL 1.1.0i 14 Aug 2018"
const char* version = OpenSSL_version(OPENSSL_VERSION);
- const size_t start = search(version, ' ') + 1;
+ const size_t first_space = search(version, ' ');
+ if (version[first_space] == '\0') {
+ return std::string("0.0.0");
+ }
+
+ const size_t start = first_space + 1;
const size_t len = search(&version[start], ' ');
return std::string(version, start, len);
}