diff --git a/src/node_crypto.cc b/src/node_crypto.cc index ec7d4f2bb5be3d..122334351afaf3 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -5715,9 +5715,9 @@ std::string GetOpenSSLVersion() { // for reference: "OpenSSL 1.1.0i 14 Aug 2018" char buf[128]; const int start = search(OPENSSL_VERSION_TEXT, 0, ' ') + 1; - const int end = search(OPENSSL_VERSION_TEXT + start, start, ' ') + 1; + const int end = search(OPENSSL_VERSION_TEXT + start, start, ' '); const int len = end - start; - snprintf(buf, sizeof(buf), "%.*s\n", len, &OPENSSL_VERSION_TEXT[start]); + snprintf(buf, sizeof(buf), "%.*s", len, &OPENSSL_VERSION_TEXT[start]); return std::string(buf); } diff --git a/test/parallel/test-process-versions.js b/test/parallel/test-process-versions.js index 8f706c6954cd2c..9a211286770586 100644 --- a/test/parallel/test-process-versions.js +++ b/test/parallel/test-process-versions.js @@ -33,6 +33,10 @@ assert(/^\d+\.\d+\.\d+(?:\.\d+)?-node\.\d+(?: \(candidate\))?$/ .test(process.versions.v8)); assert(/^\d+$/.test(process.versions.modules)); +if (common.hasCrypto) { + assert(/^\d+\.\d+\.\d+[a-z]?$/.test(process.versions.openssl)); +} + for (let i = 0; i < expected_keys.length; i++) { const key = expected_keys[i]; const descriptor = Object.getOwnPropertyDescriptor(process.versions, key);