Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect data-flow when using methodReturn node #1272

Open
jaiverma opened this issue Jun 23, 2021 · 2 comments
Open

Incorrect data-flow when using methodReturn node #1272

jaiverma opened this issue Jun 23, 2021 · 2 comments

Comments

@jaiverma
Copy link

I was using the following snippet to run a test,

int main(int argc, char *argv[]) {
  int *tmp = NULL;
  int x = 2;

  if (argc > 0) {
    tmp = &argc;
  }
  return *tmp;
}

x has no influence on the return value here, but

joern> def src = cpg.identifier.name("x") 
defined function src

joern> def sink = cpg.method.name("main").methodReturn 
defined function sink

joern> sink.reachableByFlows(src).p 
res7: List[String] = List(
  """__________________________________________________________
| tracked| lineNumber| method| file                       |
|=========================================================|
| x = 2  | 6         | main  | /Users/jai/dump/ret/main.c |
| int    | 4         | main  | /Users/jai/dump/ret/main.c |
"""
)

Using <node>.ast.isReturn works correctly though,

joern> def src = cpg.method.name("main").parameter.order(1) 
defined function src

joern> def sink = cpg.method.name("main").ast.isReturn 
defined function sink

joern> sink.reachableByFlows(src).p 
res22: List[String] = List()
@yaoyue123
Copy link

In April 2024, the problem still exists
image

@yaoyue123
Copy link

may be you can use

def sink = cpg.method.name("main").methodReturn.toReturn

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants