Skip to content

[C/C++] Is it possible to set the left-hand side of an assignment operation as the sink node in CodeQL's data flow analysis? #16046

Discussion options

You must be logged in to vote

Hi Roarcannotprogramming,

So you're successfully tracking flow from source into the argument of some_malloc, but then you want to track where the return value of some_malloc flows to. And you would like to track this all the way to the left-hand side of the assignment. Is that correct?

Indeed, the problem is that we don't allow flow from sink to sink->y without having previously seen a write to y. You can add such a taint-step yourself by doing something like:

predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
  exists(FieldAccess fa, Field f |
    fa.getTarget() = f and
    f.hasName("y") and
    f.getDeclaringType().hasName("Foo") and
    node1.asIndirectExpr() = 

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@MathiasVP
Comment options

@Roarcannotprogramming
Comment options

Answer selected by Roarcannotprogramming
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants