Skip to content

Commit bff53c5

Browse files
committed
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. PR-URL: #23678 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
1 parent f1b9546 commit bff53c5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/node_crypto.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -5715,9 +5715,9 @@ std::string GetOpenSSLVersion() {
57155715
// for reference: "OpenSSL 1.1.0i 14 Aug 2018"
57165716
char buf[128];
57175717
const int start = search(OPENSSL_VERSION_TEXT, 0, ' ') + 1;
5718-
const int end = search(OPENSSL_VERSION_TEXT + start, start, ' ') + 1;
5718+
const int end = search(OPENSSL_VERSION_TEXT + start, start, ' ');
57195719
const int len = end - start;
5720-
snprintf(buf, sizeof(buf), "%.*s\n", len, &OPENSSL_VERSION_TEXT[start]);
5720+
snprintf(buf, sizeof(buf), "%.*s", len, &OPENSSL_VERSION_TEXT[start]);
57215721
return std::string(buf);
57225722
}
57235723

test/parallel/test-process-versions.js

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ assert(/^\d+\.\d+\.\d+(?:\.\d+)?-node\.\d+(?: \(candidate\))?$/
3333
.test(process.versions.v8));
3434
assert(/^\d+$/.test(process.versions.modules));
3535

36+
if (common.hasCrypto) {
37+
assert(/^\d+\.\d+\.\d+[a-z]?$/.test(process.versions.openssl));
38+
}
39+
3640
for (let i = 0; i < expected_keys.length; i++) {
3741
const key = expected_keys[i];
3842
const descriptor = Object.getOwnPropertyDescriptor(process.versions, key);

0 commit comments

Comments
 (0)