Commit graph

72 commits

Author SHA1 Message Date
Khairul Azhar Kasmiran
3204f0c405
Use stdint types for ut64 and friends (#6276)
* Use `stdint` types for `ut64` and friends
* Use `inttypes.h` format specifiers
2026-04-22 21:43:04 +08:00
Alok Kumar Mishra
0bd98c9628
Harden diff formatting and row offset growth (#6218)
* use actual fmt buff size instead of 64
2026-04-13 08:49:05 +00:00
Giovanni
1a57d18cc4
Move ESIL into its own namespace (#6199)
* Move ESIL into its own namespace
* Remove RzAnalysisEsilInterState from RzAnalysis
* More cleanup to split cil.c from ESIL code
* Rename RzAnalysisRzilTrace to RzAnalysisILTrace
* Fix various null-derefs.
* Remove rz_analysis_get/set_esil_inter_state
* Fix use after free and leaks
2026-04-11 16:26:01 +08:00
billow
7a77b8f7bd
linter: update clang-format installation to version 20 (#5451)
* fix: format with clang-format-20
* fix: fix clang-format linter with rewrite '^#define.*/\*.*\\$'
* fix: update clang-format to version 20 in workflows and documentation
* fix: add SPDX license information to .git-blame-ignore-revs
2025-10-12 08:02:03 +08:00
Khairul Azhar Kasmiran
d3eb97e4b7
rz_print_colored_help: Add guard condition to check options length (#5427) 2025-10-03 19:30:03 +08:00
Khairul Azhar Kasmiran
46bbf79e25
-h: Convert camelCase vars to snake_case (#5426)
* Rename `maxDescLength` to `max_desc_len`
* Rename `descLength` to `desc_len`
* Rename `maxFlagAndArgLength` to `max_flag_and_arg_len`
* Rename `flagAndArgLength` to `flag_and_arg_len`
* Rename `flagLength` to `flag_len`
* Rename `argLength` to `arg_len`
* Rename `maxOptSpaces` to `max_opt_spaces`
* Rename `remainingSpaces` to `remaining_spaces`
* Rename `maxDescSpaces` to `max_desc_spaces`
* Change `flag_and_arg_len` to `flag_n_arg_len`
2025-10-02 23:02:21 +08:00
Khairul Azhar Kasmiran
ff79a14c04
-h: Refactor out colored help printing code (#5421) 2025-10-01 06:02:15 +08:00
Khairul Azhar Kasmiran
3a4134280f
-h: Refactor out column width code (#5420) 2025-09-30 17:46:45 +08:00
Khairul Azhar Kasmiran
a60c32b46e
Colorify rz-ax -h (#5413)
* Colorify `rz-ax -h`
* Hardcode `rz-find` binary name
2025-09-27 16:24:11 +08:00
Peiwei Hu
08d765d01f
hexII mode: add option to hide dots in for printable characters (#5126) 2025-05-05 21:50:58 +08:00
Rot127
99efcb6c42
Fix asm tokens leaks because they used Vector and PVector (#5019)
* Fix asm tokens leaking horrendously because they used Vector and PVector.

* Fix some resource leaks related to asm tokens

* Fix some resource leaks of the hexagon module error cases.

* Fix possible NULL ptr dereference

* Fix leak of asm tokens by fun fini on RzAsmOp.

The RzAsmOp passed here could be a previously initialized one.
With allocated asm_tokens. Doing memset just leaks those tokens.

* Simplify the copy_asm_op function

* Always fini RzAsmOp before initializeing it.

* Set asm_toks to NULL after freeing

* Fix leak in asm_bf

* Fix leaks in test_token

* Initialize all RzAsmOps with 0 and free the asm_toks on init.

In practice rz_asm_op_init() is the best place to free the asm_toks reliably.
Simply because this is always called in the old code, before an instruction is disassembled.
Only in fini() is not enough, because there are too many place it is not called, leaking the tokens.

* Fresh mind, new attempt. Fini asmop at all occurrences of rz_asm_disassemble
2025-03-31 10:39:53 +08:00
Rot127
bdd913ab5e
Fix definition of alignment
* Fix definition of alignment.

Alignments for code and data is not defind for 0, bubt nonetheless it
was assigned this value everytwhere. This changes the default value to 1.

* Enforce an alignment of at least 1.

* Fix alignment checks (default is now 1).

* Fix alignment check. 1 was assumed to be valid.

* Fix places where an alignment of 0 is considered still a valid value.

* Fix integration test with invalid alignment

* Remove debug printf

* Remove addrmod member.

It was pressumingly used to indicate aligned addresses in print mode.
But it wasn't documented and the usefulness is dubious.
Since it is easy to spot for users to see if addresses are aligned or not anyways.

* Fix tests after cherry-pick

* Fix rz-find test which consumed the '-X' as number value for '-a'.

* Fix case of arch module not defining value alignments.
2025-02-14 01:27:47 +08:00
Khairul Azhar Kasmiran
d0f8d4867c
pxi: Add missing : at Last_Offset+1 (#4811) 2024-12-31 19:38:55 +08:00
Giovanni
db1e4993a0
Replace strdup with rz_str_dup (#4634) 2024-09-15 19:12:07 +08:00
Anton Kochkov
51bd32c8bf
util/print: remove some use of cb_printf (#4538) 2024-06-07 01:16:48 +08:00
pelijah
b8ebd5ac42
Add missing vector foreach macros to clang-format cfg (#4456)
* Add rz_vector_foreach to clang-format cfg
* Add other vector foreach macros
2024-04-22 07:16:46 +08:00
Anton Kochkov
60e93b28ca
util/print: emove cb_eprintf() (#4235) 2024-02-15 18:12:09 +08:00
Anton Kochkov
8e4faa3906
Remove scr.rainbow option (#4199)
* Remove scr.rainbow option
* Update librz/util/float/float.c
2024-02-10 12:02:50 +08:00
Rot127
5afc51f0e2
Replace current regex engine with PCRE2 (#4185)
* Replace OpenBSD regex library with PCRE2.

PCRE2 has way better performance than the OpenBSD
library (something around 20 times faster).

The following flags are enabled for every pattern:

- PCRE2_UTF
- PCRE2_MATCH_INVALID_UTF
- PCRE2_NO_UTF_CHECK

All the others are optional.

Changes made:

- Adds PCRE2 as subproject.
- Changes the API away from POSIX to PCRE2.
- Edits many regex patterns because:
 - ' ' is skipped in patterns, if the EXTENDED flag is set for matching. '\s' must be set now.
 - '.' doesn't match newlines by default.
- Changes the API so matches and their groups are bundled into PVectors.
- Moves the regex component to rz_util.

* Fix cross build - add copy of PCRE2 dependecy

Meson currently doesn't support subprojects to be native and non-native at the same time.
See: https://github.com/mesonbuild/meson/issues/10947
Unfortunately, sdb depends on rz_util which in turn depends on PCRE2.
Excluding PCRE2 from the native build makes linking of rz_util not possible anymore.
Adding it, will make Meson complain that the dependencies cannot be mixed.

Hence, we compile a copy of PCRE2 for the native build if required.
2024-02-05 12:51:16 +08:00
byteninjaa0
5c28709cb2
Coloring help output of toos (<tool> -h output) (#4046) 2024-01-09 07:18:31 +08:00
wargio
a9131cede7 Remove hidden static in rz_str_pad 2024-01-06 23:30:07 +08:00
wargio
0b075c8388 Remove hidden static in print_addr 2024-01-06 23:30:07 +08:00
Giovanni
68fa2d1887
Remove useless null strings (#3457) 2023-04-11 17:42:40 +08:00
Anton Kochkov
a9096718e9
Coverity fixes - memory leaks, NULL dereferences (#3339)
* Fix CID 398788 - memory leak

* Fix CID 397077 - remove useless comparison

* Fix CID 397076 - remove useless comparison

* Fix CID 397074 - remove useless comparison

* Fix CID 396207 - memory leak

* Fix CID 392014 - bad shift

* Fix CID 391965 - NULL dereference

* Fix CID 390010 - wrong assert use

* Fix CID 378899 - unitialized variable

* Fix CID 378859 - integer overflow

* Fix CID 366898 - remove useless comparison

* Fix CID 364035 - NULL dereference

* Fix CID 317001 - closing "-1" file descriptor

* Fix CID 316991 - lseek() to negative position

* Fix CID 316172 - mmap() with negative size

* Fix CID 401510 - double free

* Fix CID 395360 - remove useless comparison

* Fix CID 352574 - negative loop bound

* Fix CID 316187 - memory leak

* Fix CID 395425 - memory leak

* Fix CID 316975 - buffer overrun

* Fix CID 316947 - memory leak

* Fix CID 398474 - integer overflow
2023-02-04 20:01:42 +08:00
Giovanni
4a9740d11d
Fix pxj output (#3290) 2023-01-14 14:14:34 +08:00
Anton Kochkov
f2ca09fe24
Extract histograms and bars into RzCons (#3189) 2022-11-17 14:41:50 +01:00
wargio
ab5c0cb869 Fix endianness in px command 2022-10-20 23:12:58 +02:00
billow
0908b65bc3
Convert px[ dDhHwWqQol] to rzshell
* `pxd` -> `pxd 4`
* `pxd<N> [len]` -> `pxd <N> [len]`
* expose APIs:
- `rz_core_print_cmp`
- `rz_core_print_dump`
- `rz_core_print_hexdump_`
- `rz_core_print_hexdump_byline`
* test for `pxW` `pxH`
* move `void rz_print_section` -> `const char *rz_print_section`
* `pxd` -> `pxd[ hwq]`
* `pxc`
* `pxAv` -> `pxAl`
* `pxt.` -> removed ?
* `px/` -> keep
* `pxf` -> TODO: not found old code ?
2022-08-04 09:11:22 +08:00
wingdeans
a6a7a5f530 Fix annotation inconsistencies 2022-08-03 00:29:56 -04:00
Rot127
b9fa2be193
Asm tokens fixes (#2855)
* Replace on s390x failing tms320 c55x test with c55x+ test.

* Fix resource leaks of parse paramters.

* Revive unreachable code.

* Raplace test with one which has not a different asm string in Capstone v3.

* Rename `new` to `newt` since `new` is a keyword and should not be used as var name.
2022-07-30 21:24:49 +08:00
billow
10d7c697b4
Remove cb_printf() from RzPrint
* move `rz_print_jsondump()` -> `rz_print_jsondump_str()`
* move `rz_print_hexdiff()` -> `rz_print_hexdiff_str()`
2022-07-29 09:11:55 +08:00
billow
df602944d7
rz_print_hexdump() refactoring (#2841)
* Move `rz_print_hexdump()` -> `rz_print_hexdump_str()`
2022-07-28 00:24:25 +08:00
Rot127
c009f8d7a3
Tokenize and colorize asm strings (#2417)
This introduces the ability to split asm strings into tokens and assign a type to them.

This means:
* Each asm strings is assigned a list of tokens. Each token points to a sub-string.
* A token has a type attached which describes it (e.g. register token, operator token, mnemonic token etc.)
* A generic parsing method is introduced which splits an asm string into tokens. The pattern it parses is `<mnem> <op> <op> ...`.
* Instead of the generic method, plugins can create the token strings on their own.
* An API method was introduced to help plugins implement their own parsing methods via regex patterns.
* Custom token strings are stored in `RzAsmOp.asm_toks`

Additionally the coloring of asm strings is now exclusively done via the token strings.
* For this a function was added to colorize tokenized asm strings according to their token types.
2022-07-27 08:52:01 -04:00
GustavoLCR
19546cb498 Print: Memoize number of rows for current print 2022-06-19 17:29:42 +08:00
wargio
41aa8ec196 Moved rz_print_rowlog/_done to rz_core_notify_begin/_done under rz_core 2022-03-28 09:12:16 +08:00
wargio
f2f45da044 Removed rz_print_c because unused. 2022-03-28 09:12:16 +08:00
wargio
2031812c16 Removed rz_print_unset_flags because unused. 2022-03-28 09:12:16 +08:00
wargio
f002ef3acb Moved rz_print_hex_from_base2 under rz-ax since it is used only there. 2022-03-28 09:12:16 +08:00
wargio
15a5b7c3e3 Removed rz_print_hexdump_simple because unused. 2022-03-28 09:12:16 +08:00
wargio
5c64ebf73e Removed rz_print_hexpairs because unused. 2022-03-28 09:12:16 +08:00
Giovanni
db580beb22
Refactoring for rz_print_2bpp_* and ps<cmd> (#2376)
* Moved rz_print_2bpp_* under rz_core
* Moved rz_print_string to rz_str_stringify_raw_buffer
* Added test for print urlencode and added pu0
* Removed RzCoreString and implemented utf32be/utf16be
2022-03-04 15:30:46 +01:00
wargio
5db565e954 removed pz commands and aliases 2022-03-03 12:56:12 +01:00
wargio
165a38207b moved rz_print_columns into core and use rz_cons 2022-02-28 14:33:07 +01:00
wargio
02cf266820 removed rz_print_portionbar 2022-02-28 14:33:07 +01:00
wargio
808e5014c2 removed rz_print_mute 2022-02-28 14:33:07 +01:00
Rot127
3d71687d5e
Add Hexagon IDE conforming packet syntax (#2209)
* Add option to print instruction packets syntax in objdump style.
* Add the config `plugins.hexagon.sdk` to toggle syntax.
* Remove unused trimming.
* Trim only newlines from the assembly string.
* Add new trim functions to allow trimming of certain chars.
2022-02-14 02:27:55 +08:00
Dhruv Maroo
34d345d884 Format according to clang-format-13 2021-11-25 15:44:28 +08:00
Anton Kochkov
37be0b685d
Fix char array subscript warning (#1515) 2021-08-25 17:45:45 +08:00
Giovanni
4e3bbf1d9d
Fix compiler warnings gnu/arc*.c syscall.c print.c debug_gdb.c (#1227)
* Fixed memory leak in rz_syscall

* Fixed warning of null format on sprintf

* Fixed warning of null fmt on printf

* fixed array subscript 5 is above array bounds of ‘char[5]’
2021-06-20 21:49:08 +08:00
Giovanni
be4288847d
Fix some Code Scanning Alerts (#1222)
* Fixed integer overflow on `rz-diff`
* Fixed memory leak on canalysis.c
* Fixed memleak on canalysis.c
* Refactored base2 method
2021-06-18 16:25:37 +08:00