Skip to content

validate arg indirect attribute before indexing direction array - #8850

Open
Nussu06 wants to merge 1 commit into
cppcheck-opensource:mainfrom
Nussu06:library-indirect-bounds
Open

validate arg indirect attribute before indexing direction array#8850
Nussu06 wants to merge 1 commit into
cppcheck-opensource:mainfrom
Nussu06:library-indirect-bounds

Conversation

@Nussu06

@Nussu06 Nussu06 commented Sep 13, 2026

Copy link
Copy Markdown

loadFunction writes ac.direction[indirect] where indirect comes straight from the indirect attribute of an <arg> element in a --library cfg file, with no range check, so a value like indirect="1000000" or indirect="-5" writes outside the fixed 3-element direction array. Reject an out-of-range indirect with BAD_ATTRIBUTE_VALUE, matching the bounds check getArgDirection already applies when reading the same array.

Comment thread lib/library.cpp
}
if (const char* const argIndirect = functionnode->Attribute("indirect")) {
const int indirect = strToInt<int>(argIndirect);
if (indirect < 0 || indirect >= static_cast<int>(ac.direction.size()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants