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

Add (i)CFG node type annotations + bug fix #4221

Merged
merged 14 commits into from
Feb 14, 2024
Merged

Conversation

Rot127
Copy link
Member

@Rot127 Rot127 commented Feb 13, 2024

Your checklist for this pull request

  • I've read the guidelines for contributing to this repository
  • I made sure to follow the project's coding style
  • I've documented or updated the documentation of every function and struct this PR changes. If not so I've explained why.
  • I've added tests that prove my fix is effective or that my feature works (if possible)
  • I've updated the rizin book with the relevant information (if needed)

Detailed description

Fixes the bug that the buffer was not read again, before nodes to RzAnalysisOp.jump/fail were added.

Additionally, and for testing specifically this, annotations are added to the CFG/iCFG nodes.

New annotations:

  • None: no-utf8: .
  • Cond: no-utf8: c
  • Entry: no-utf8: e
  • Return: no-utf8: r
  • Call: no-utf8: C
  • Exit: no-utf8: E

Exit is not yet tested, because it is not implemented yet. Exit nodes are nodes which exit the program abnormally, although the procedure should normally return (e.g. call to abort()).

            ;-- ignore_call:
            0x080000c3      push  rbp
            0x080000c4      mov   rbp, rsp
            0x080000c7      call  reloc.target.rand                    ; RELOC 32 rand
            0x080000cc      nop
            0x080000cd      pop   rbp
            0x080000ce      ret
>rizin -Qc 's sym.ignore_call
agF
' test/bins/elf/analysis/x86_cfg_test
┌─────────────────┐
│  0x80000c3 ↓    │
└─────────────────┘
    v
    │
    │
┌─────────────────┐
│  0x80000c4 ○    │
└─────────────────┘
    v
    │
    │
┌─────────────────┐
│  0x80000c7 ⇢    │
└─────────────────┘
    v
    │
    │
┌─────────────────┐
│  0x80000cc ○    │
└─────────────────┘
    v
    │
    │
┌─────────────────┐
│  0x80000cd ○    │
└─────────────────┘
    v
    │
    │
┌─────────────────┐
│  0x80000ce ↑    │
└─────────────────┘

> rizin -Qc 's sym.ignore_call
e scr.utf8=0 ; agF
' test/bins/elf/analysis/x86_cfg_test
.---------------.
|  0x80000c3 e  |
`---------------'
    v
    |
    |
.---------------.
|  0x80000c4 .  |
`---------------'
    v
    |
    |
.---------------.
|  0x80000c7 C  |
`---------------'
    v
    |
    |
.---------------.
|  0x80000cc .  |
`---------------'
    v
    |
    |
.---------------.
|  0x80000cd .  |
`---------------'
    v
    |
    |
.---------------.
|  0x80000ce r  |
`---------------'

Test plan

All green + added

Closing issues

...

@Rot127 Rot127 changed the title Extract buffer read and analyze into function. Add (i)CFG node type annotations + bug fix Feb 14, 2024
@Rot127 Rot127 marked this pull request as ready for review February 14, 2024 06:53
@Rot127 Rot127 requested a review from karliss February 14, 2024 06:54
librz/core/cagraph.c Outdated Show resolved Hide resolved
librz/core/agraph.c Outdated Show resolved Hide resolved
librz/core/agraph.c Show resolved Hide resolved
librz/core/agraph.c Outdated Show resolved Hide resolved
librz/core/agraph.c Outdated Show resolved Hide resolved
librz/util/graph_drawable.c Show resolved Hide resolved
test/db/cmd/cmd_graph Outdated Show resolved Hide resolved
Copy link
Member

@XVilka XVilka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rot127
Copy link
Member Author

Rot127 commented Feb 14, 2024

Blind fix, though I think it was the leak. rz_str_append() frees the pointer for realloc.

@XVilka XVilka merged commit 7ab605a into rizinorg:dev Feb 14, 2024
44 checks passed
@Rot127 Rot127 deleted the cfg-fixes branch February 14, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants