From: Francis Dupont Date: Tue, 12 May 2026 09:45:45 +0000 (+0200) Subject: [#3991] Fixed CWE 398 uselessCallsSubstr X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=7914017b2d238edfac1e04a91f939feb5355fcfd;p=thirdparty%2Fkea.git [#3991] Fixed CWE 398 uselessCallsSubstr --- diff --git a/src/lib/testutils/io_utils.cc b/src/lib/testutils/io_utils.cc index f8adbe23c4..950f46a643 100644 --- a/src/lib/testutils/io_utils.cc +++ b/src/lib/testutils/io_utils.cc @@ -67,7 +67,7 @@ std::string decommentJSONfile(const std::string& input_file) { // First, let's get rid of the # comments size_t hash_pos = line.find("#"); if (hash_pos != string::npos) { - line = line.substr(0, hash_pos); + line.resize(hash_pos); } // Second, let's get rid of the // comments @@ -76,7 +76,7 @@ std::string decommentJSONfile(const std::string& input_file) { if ((dblslash_pos != string::npos) && ((dblslash_pos == 0) || ((unsigned) line[dblslash_pos - 1] <= 32))) { - line = line.substr(0, dblslash_pos); + line.resize(dblslash_pos); } // Now the tricky part: c comments. @@ -94,7 +94,7 @@ std::string decommentJSONfile(const std::string& input_file) { line = line.replace(begin_pos, end_pos + 2, end_pos + 2 - begin_pos, ' '); in_comment = false; } else { - line = line.substr(0, begin_pos); + line.resize(begin_pos); } } else { if (in_comment && end_pos != string::npos) {