Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,8 @@ Library::Error Library::loadFunction(const tinyxml2::XMLElement * const node, co
}
if (const char* const argIndirect = functionnode->Attribute("indirect")) {
const int indirect = strToInt<int>(argIndirect);
if (indirect < 0 || indirect >= static_cast<int>(ac.direction.size()))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please suppress this

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alert on this line is premium-cert-int31-c (I checked the SARIF from the PR's premium run), and that id is in cppcheckpremium-suppressions on main since #8915. An inline suppression would be redundant with that, so I merged main into the branch instead, which lets the Premium job pick up the updated list. No change to the diff itself. The workflow runs for the new push are waiting for approval, so I can't confirm the job is green yet. If you'd still prefer an inline cppcheck-suppress here, I'll add it.

return Error(ErrorCode::BAD_ATTRIBUTE_VALUE, argIndirect);
Comment thread
danmar marked this conversation as resolved.
ac.direction[indirect] = dir; // TODO: handle multiple directions/indirect levels
}
else
Expand Down
17 changes: 17 additions & 0 deletions test/testlibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,23 @@ class TestLibrary : public TestFixture {

// comma followed by dot
LOADLIB_ERROR_INVALID_RANGE("-10:0,.5:");

// arg indirect out of range (index into ArgumentChecks::direction)
LOADLIBERROR("<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"foo\">\n"
" <arg nr=\"1\" direction=\"in\" indirect=\"1000000\"/>\n"
" </function>\n"
"</def>",
Library::ErrorCode::BAD_ATTRIBUTE_VALUE);

LOADLIBERROR("<?xml version=\"1.0\"?>\n"
"<def>\n"
" <function name=\"foo\">\n"
" <arg nr=\"1\" direction=\"out\" indirect=\"-5\"/>\n"
" </function>\n"
"</def>",
Library::ErrorCode::BAD_ATTRIBUTE_VALUE);
}

void loadLibCombinations() const {
Expand Down