Skip to content

Commit

Permalink
src: clang build warning fix
Browse files Browse the repository at this point in the history
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 Jul 20, 2019
1 parent 871a60c commit 22daf95
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/node_metadata.cc
Expand Up @@ -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);
Expand Down

0 comments on commit 22daf95

Please sign in to comment.