Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto: strip unwanted space from openssl version #23678

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
crypto: strip unwanted space from openssl version
Remove trailing " \n" from `process.versions.openssl`.

d3d6cd3 was incorrectly printing this trailer, but because the
target buffer size was claimed to be the length of the version string,
the trailer was truncated off.

9ed4646 corrected the target buffer size, but then the trailer
started to appear in process.versions.

Added a test to check for regressions.
sam-github committed Oct 22, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 2ee1cb18cb667875ae285a70e074e982f311a01e
4 changes: 2 additions & 2 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
@@ -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);
}

4 changes: 4 additions & 0 deletions test/parallel/test-process-versions.js
Original file line number Diff line number Diff line change
@@ -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);