C++: Mark fprintf and friends as a partial write of the stream argument.

This commit is contained in:
Mathias Vorreiter Pedersen
2025-08-18 18:15:14 +02:00
parent 6a57da79de
commit af00e46fc8
2 changed files with 11 additions and 1 deletions

View File

@@ -170,6 +170,16 @@ abstract class FormattingFunction extends ArrayFunction, TaintFunction {
output.isParameterDeref(this.getOutputParameterIndex(_))
)
}
final override predicate isPartialWrite(FunctionOutput output) {
exists(int outputParameterIndex |
output.isParameterDeref(outputParameterIndex) and
// We require the output to be a stream since that definitely means that
// it's a partial write. If it's not a stream then it will most likely
// fill the whole buffer.
outputParameterIndex = this.getOutputParameterIndex(true)
)
}
}
/**

View File

@@ -840,6 +840,6 @@ int f7(void)
{
FILE* fp = (FILE*)indirect_source();
fprintf(fp, "");
indirect_sink(fp); // $ MISSING: ast,ir
indirect_sink(fp); // $ ir MISSING: ast
return 0;
}