File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -48,14 +48,23 @@ Metadata metadata;
4848
4949#if HAVE_OPENSSL
5050static constexpr size_t search (const char * s, char c, size_t n = 0 ) {
51- return *s == c ? n : search (s + 1 , c, n + 1 );
51+ return *s == ' \0 ' ? n : (*s == c ? n : search (s + 1 , c, n + 1 ) );
5252}
5353
5454static inline std::string GetOpenSSLVersion () {
5555 // sample openssl version string format
5656 // for reference: "OpenSSL 1.1.0i 14 Aug 2018"
5757 const char * version = OpenSSL_version (OPENSSL_VERSION);
58- const size_t start = search (version, ' ' ) + 1 ;
58+ const size_t first_space = search (version, ' ' );
59+
60+ // When Node.js is linked to an alternative library implementing the
61+ // OpenSSL API e.g. BoringSSL, the version string may not match the
62+ // expected pattern. In this case just return “0.0.0” as placeholder.
63+ if (version[first_space] == ' \0 ' ) {
64+ return " 0.0.0" ;
65+ }
66+
67+ const size_t start = first_space + 1 ;
5968 const size_t len = search (&version[start], ' ' );
6069 return std::string (version, start, len);
6170}
You can’t perform that action at this time.
0 commit comments