Skip to content
Permalink
Browse files

src: clang build warning fix

fix UB with string concatenations. += operator makes things
clearer for compiler's perspective.

PR-URL: #28480
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information...
devnexen authored and targos committed Jun 30, 2019
1 parent 871a60c commit 22daf952dea7abe094ad6b3f5ceed107ce7524a0
Showing with 4 additions and 2 deletions.
  1. +4 −2 src/node_metadata.cc
@@ -34,8 +34,10 @@ std::string GetOpenSSLVersion() {
// sample openssl version string format
// 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, ' ');
const char* etext = OPENSSL_VERSION_TEXT;
const int start = search(etext, 0, ' ') + 1;
etext += start;
const int end = search(etext, start, ' ');
const int len = end - start;
snprintf(buf, sizeof(buf), "%.*s", len, &OPENSSL_VERSION_TEXT[start]);
return std::string(buf);

0 comments on commit 22daf95

Please sign in to comment.
You can’t perform that action at this time.