Skip to content

[Bug][C] Problem with dataflow when array index is a variable #5666

@van-dalf

Description

@van-dalf

Describe the bug
Dataflow is not generated correctly for assignments to arrays when the array index is a variable

To Reproduce

#include <stdio.h>

int main(int argc, char **argv) {

    char *args[2];
    int idx = 0;

    args[idx] = argv[1];
    args[1] = argv[1];

    printf("Arg: %s", args[0]);
    printf("Arg: %s", args[1]);

}

Import above code and run the query

cpg.call("printf").argument.reachableByFlows(cpg.method("main").parameter).p

Only the flow to the second printf-call is detected

Expected behavior
Flows to both printf calls are detected

Desktop (please complete the following information):

  • Joern Version 4.0.302

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions