mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Merge topic 'pvs-fixes'
e2f4b9bedcpvs-studio: (V522) Prevent possible null-pointer dereference in RemoveRPathELF77b874baa8pvs-studio: (V1086) Fix buffer writesa77b7aa836pvs-studio: (V557) Harden array boundary checks7217af55dapvs-studio: (V555) Clarify size_type comparison Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !12077
This commit is contained in:
+1
-7
@@ -6,17 +6,13 @@
|
||||
//-V::508
|
||||
# The 'x' variable is assigned values twice successively. Perhaps this is a mistake.
|
||||
//-V::519
|
||||
# Possible null pointer dereference.
|
||||
//-V::522
|
||||
# Constant value is represented by an octal form.
|
||||
//-V::536
|
||||
# Iterators are passed as arguments to 'Foo' function. Consider inspecting the expression.
|
||||
//-V::539
|
||||
# Expression is always true/false.
|
||||
//-V::547
|
||||
# Expression of the 'A - B > 0' kind will work as 'A != B'.
|
||||
//-V::555
|
||||
# Possible array overrun.
|
||||
# Array underrun/overrun is possible.
|
||||
//-V::557
|
||||
# Part of conditional expression is always true/false.
|
||||
//-V::560
|
||||
@@ -90,8 +86,6 @@
|
||||
//-V::1071
|
||||
# Conditional initialization inside the constructor may leave some members uninitialized.
|
||||
//-V::1077
|
||||
# Call of the 'Foo' function will lead to buffer underflow.
|
||||
//-V::1086
|
||||
# Waiting on condition variable without predicate. A thread can wait indefinitely or experience a spurious wake-up.
|
||||
//-V::1089
|
||||
# The 'emplace' / 'insert' function call contains potentially dangerous move operation. Moved object can be destroyed even if there is no insertion.
|
||||
|
||||
@@ -314,9 +314,12 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
|
||||
char secondLine[512] = "";
|
||||
char thirdLine[512] = "";
|
||||
if (process) {
|
||||
memset(firstLine, ' ', 68);
|
||||
memset(secondLine, ' ', 68);
|
||||
memset(thirdLine, ' ', 68);
|
||||
std::fill_n(firstLine, 68, ' ');
|
||||
firstLine[68] = '\0';
|
||||
std::fill_n(secondLine, 68, ' ');
|
||||
secondLine[68] = '\0';
|
||||
std::fill_n(thirdLine, 68, ' ');
|
||||
thirdLine[68] = '\0';
|
||||
} else {
|
||||
if (this->OkToGenerate) {
|
||||
snprintf(firstLine, sizeof(firstLine),
|
||||
@@ -340,7 +343,8 @@ void cmCursesMainForm::PrintKeys(int process /* = 0 */)
|
||||
move(y - 4, 0);
|
||||
char fmt[512] = "Keys: [enter] Edit an entry [d] Delete an entry";
|
||||
if (process) {
|
||||
memset(fmt, ' ', 57);
|
||||
std::fill_n(fmt, 57, ' ');
|
||||
fmt[57] = '\0';
|
||||
}
|
||||
printw(fmt_s, fmt);
|
||||
move(y - 3, 0);
|
||||
|
||||
@@ -391,7 +391,7 @@ static bool DumpFileWithLlvmNm(std::string const& nmPath, char const* filename,
|
||||
line.c_str());
|
||||
return false;
|
||||
}
|
||||
if (line.size() < sym_end + 1) {
|
||||
if (line.size() < sym_end) {
|
||||
fprintf(stderr, "Couldn't parse llvm-nm output line: %s\n",
|
||||
line.c_str());
|
||||
return false;
|
||||
|
||||
@@ -93,7 +93,7 @@ void cmStringReplaceHelper::ParseReplaceExpression()
|
||||
this->Replacements.emplace_back(
|
||||
this->ReplaceExpression.substr(l, r - l));
|
||||
} else {
|
||||
if (r - l > 0) {
|
||||
if (r > l) {
|
||||
this->Replacements.emplace_back(
|
||||
this->ReplaceExpression.substr(l, r - l));
|
||||
}
|
||||
|
||||
@@ -3895,7 +3895,8 @@ static cm::optional<bool> RemoveRPathELF(std::string const& file,
|
||||
// There is no RPATH or RUNPATH anyway.
|
||||
return true;
|
||||
}
|
||||
if (se_count == 2 && se[1]->IndexInSection < se[0]->IndexInSection) {
|
||||
if (se_count == 2 && se[0] && se[1] &&
|
||||
se[1]->IndexInSection < se[0]->IndexInSection) {
|
||||
std::swap(se[0], se[1]);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,14 +81,16 @@ bool cmTargetPropCommandBase::HandleArguments(
|
||||
}
|
||||
|
||||
bool prepend = false;
|
||||
if ((flags & PROCESS_BEFORE) && args[argIndex] == "BEFORE") {
|
||||
if ((flags & PROCESS_BEFORE) && argIndex < args.size() &&
|
||||
args[argIndex] == "BEFORE") {
|
||||
if (args.size() < 3) {
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
prepend = true;
|
||||
++argIndex;
|
||||
} else if ((flags & PROCESS_AFTER) && args[argIndex] == "AFTER") {
|
||||
} else if ((flags & PROCESS_AFTER) && argIndex < args.size() &&
|
||||
args[argIndex] == "AFTER") {
|
||||
if (args.size() < 3) {
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
@@ -97,7 +99,8 @@ bool cmTargetPropCommandBase::HandleArguments(
|
||||
++argIndex;
|
||||
}
|
||||
|
||||
if ((flags & PROCESS_REUSE_FROM) && args[argIndex] == "REUSE_FROM") {
|
||||
if ((flags & PROCESS_REUSE_FROM) && argIndex < args.size() &&
|
||||
args[argIndex] == "REUSE_FROM") {
|
||||
if (args.size() != 3) {
|
||||
this->SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
|
||||
@@ -246,7 +246,8 @@ static bool testUVStreambufRead(
|
||||
<< std::endl;
|
||||
goto end;
|
||||
}
|
||||
if (std::memcmp(inputData.data(), outputData, 64)) {
|
||||
if (std::memcmp(inputData.data(), outputData, //-V1086 Ignore underflow
|
||||
64)) {
|
||||
std::cout << "Read data does not match write data" << std::endl;
|
||||
goto end;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user