C++: Iterator derefs are partial writes #18674
Open
+4
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #15633 we started to interpret flow out of a non-MaD dataflow/taint-flow model (i.e., a class that extends DataFlowFunction or TaintFlowFunction) as totally overwriting the destination buffer.
Obviously, since not all functions overwrite the entire destination buffer, we had to come up with a way to opt out of this now-default behavior. So we added an
isPartialWrite
predicate that could be overwritten on classes that did not overwrite the entire buffer. In #15633 I went through most of our classes to add this, but I see that I missed theoperator*
functions in iterators.Why do
operator*
even have flow out, you may ask? That's a good question! It stems from a pretty neat idea we had back in the days of AST dataflow that we could provide flow fromsource()
tomyIterator
in:(which would then have another step to its underlying container) by adding a dataflow model for
operator*
from the return value to the qualifier. That is, the opposite direction of what you'd normally add for flow out ofoperator*
(the same idea is used in dataflow)The end result is that
operator*
actually does "write" to its qualifier, and this write is obviously not meant to totally overwrite the qualifier.For various reasons, it's not actually possible to observe any missing flow because of this, but I'm currently working on another PR where this matters.