Skip to content

Commit 4341fab

Browse files
committed
C++: Reject invalid results from getFirstFormatArgumentIndex()
1 parent 5315a5c commit 4341fab

File tree

2 files changed

+1
-2
lines changed

2 files changed

+1
-2
lines changed

cpp/ql/lib/semmle/code/cpp/models/implementations/Printf.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ private class Fprintf extends FormattingFunction, NonThrowingFunction {
5050
override int getFormatParameterIndex() { result = 1 }
5151

5252
override int getOutputParameterIndex(boolean isStream) { result = 0 and isStream = true }
53-
54-
override int getFirstFormatArgumentIndex() { result = 2 }
5553
}
5654

5755
/**

cpp/ql/lib/semmle/code/cpp/models/interfaces/FormattingFunction.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ abstract class FormattingFunction extends ArrayFunction, TaintFunction {
125125
// The formatting function either has a definition in the snapshot, or all
126126
// `DeclarationEntry`s agree on the number of parameters (otherwise we don't
127127
// really know the correct number)
128+
result > 0 and // Avoid invalid declarations
128129
if this.hasDefinition()
129130
then result = this.getDefinition().getNumberOfParameters()
130131
else result = this.getNumberOfExplicitParameters()

0 commit comments

Comments
 (0)