Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d814fe9

Browse filesBrowse files
codebytererichardlau
authored andcommitted
src: account for OpenSSL unexpected version
PR-URL: #54038 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent ac3a390 commit d814fe9
Copy full SHA for d814fe9

1 file changed

+11-2Lines changed: 11 additions & 2 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_metadata.cc‎

Copy file name to clipboardExpand all lines: src/node_metadata.cc
+11-2Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,23 @@ Metadata metadata;
4343

4444
#if HAVE_OPENSSL
4545
static constexpr size_t search(const char* s, char c, size_t n = 0) {
46-
return *s == c ? n : search(s + 1, c, n + 1);
46+
return *s == '\0' ? n : (*s == c ? n : search(s + 1, c, n + 1));
4747
}
4848

4949
static inline std::string GetOpenSSLVersion() {
5050
// sample openssl version string format
5151
// for reference: "OpenSSL 1.1.0i 14 Aug 2018"
5252
const char* version = OpenSSL_version(OPENSSL_VERSION);
53-
const size_t start = search(version, ' ') + 1;
53+
const size_t first_space = search(version, ' ');
54+
55+
// When Node.js is linked to an alternative library implementing the
56+
// OpenSSL API e.g. BoringSSL, the version string may not match the
57+
// expected pattern. In this case just return “0.0.0” as placeholder.
58+
if (version[first_space] == '\0') {
59+
return "0.0.0";
60+
}
61+
62+
const size_t start = first_space + 1;
5463
const size_t len = search(&version[start], ' ');
5564
return std::string(version, start, len);
5665
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.