Skip to content

Conversation

@gemesa
Copy link
Contributor

@gemesa gemesa commented May 7, 2025

Fixes #5473

The reason for the mismatch is that previously different APIs have been used.

Before:

joern> cpg.method("vuln").l
val res1: List[io.shiftleft.codepropertygraph.generated.nodes.Method] = List(
  Method(
    astParentFullName = "/home/gemesa/git-repos/tmp/vuln:<global>",
    astParentType = "NAMESPACE_BLOCK",
    code = """
int vuln(void)

{
  int iVar1;
  char acStack_8 [8];
  
  printf("Enter some text: ");
  __isoc23_scanf(&DAT_004007f8,acStack_8);
  iVar1 = puts(acStack_8);
  return iVar1;
}

""",
    columnNumber = Some(value = -1),
    columnNumberEnd = None,
    filename = "/home/gemesa/git-repos/tmp/vuln",
    fullName = "vuln",
    genericSignature = "<empty>",
    hash = None,
    isExternal = false,
    lineNumber = Some(value = 4196196),
    lineNumberEnd = Some(value = -1),
    name = "vuln",
    offset = None,
    offsetEnd = None,
    order = 0,
    signature = "undefined vuln(void)"
  )
)
                                                                                                                      
joern>

After:

joern> cpg.method("vuln").l
val res1: List[io.shiftleft.codepropertygraph.generated.nodes.Method] = List(
  Method(
    astParentFullName = "/home/gemesa/git-repos/tmp/vuln:<global>",
    astParentType = "NAMESPACE_BLOCK",
    code = """
int vuln(void)

{
  int iVar1;
  char acStack_8 [8];
  
  printf("Enter some text: ");
  __isoc23_scanf(&DAT_004007f8,acStack_8);
  iVar1 = puts(acStack_8);
  return iVar1;
}

""",
    columnNumber = Some(value = -1),
    columnNumberEnd = None,
    filename = "/home/gemesa/git-repos/tmp/vuln",
    fullName = "vuln",
    genericSignature = "<empty>",
    hash = None,
    isExternal = false,
    lineNumber = Some(value = 4196196),
    lineNumberEnd = Some(value = -1),
    name = "vuln",
    offset = None,
    offsetEnd = None,
    order = 0,
    signature = "int vuln(void);"
  )
)
                                                                                                                      
joern>

@itsacoderepo
Copy link
Contributor

Thanks for the PR!

DON'T merge yet as it might have impact on tests!

I'll merge this on 19.05., when i can handle failures and adjust expectations.

@max-leuthaeuser
Copy link
Contributor

Any updates on this PR @itsacoderepo?

@max-leuthaeuser max-leuthaeuser merged commit 2030926 into joernio:master Jun 16, 2025
6 checks passed
@gemesa gemesa deleted the ghidra-signature branch June 16, 2025 15:26
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

Successfully merging this pull request may close these issues.

[Bug] [ghidra2cpg] signature does not match the code

3 participants