Skip to content

Commit

Permalink
C++: Reject invalid results from getFirstFormatArgumentIndex()
Browse files Browse the repository at this point in the history
  • Loading branch information
calumgrant committed Oct 17, 2024
1 parent 5315a5c commit 4341fab
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 2 deletions.
2 changes: 0 additions & 2 deletions cpp/ql/lib/semmle/code/cpp/models/implementations/Printf.qll
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ private class Fprintf extends FormattingFunction, NonThrowingFunction {
override int getFormatParameterIndex() { result = 1 }

override int getOutputParameterIndex(boolean isStream) { result = 0 and isStream = true }

override int getFirstFormatArgumentIndex() { result = 2 }
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ abstract class FormattingFunction extends ArrayFunction, TaintFunction {
// The formatting function either has a definition in the snapshot, or all
// `DeclarationEntry`s agree on the number of parameters (otherwise we don't
// really know the correct number)
result > 0 and // Avoid invalid declarations
if this.hasDefinition()
then result = this.getDefinition().getNumberOfParameters()
else result = this.getNumberOfExplicitParameters()
Expand Down

0 comments on commit 4341fab

Please sign in to comment.