File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -43,14 +43,23 @@ Metadata metadata;
43
43
44
44
#if HAVE_OPENSSL
45
45
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 ) );
47
47
}
48
48
49
49
static inline std::string GetOpenSSLVersion () {
50
50
// sample openssl version string format
51
51
// for reference: "OpenSSL 1.1.0i 14 Aug 2018"
52
52
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 ;
54
63
const size_t len = search (&version[start], ' ' );
55
64
return std::string (version, start, len);
56
65
}
You can’t perform that action at this time.
0 commit comments