Commit graph

99 commits

Author SHA1 Message Date
wargio
7685bfe90e remove rz_mem_swaporcopy 2022-10-20 23:12:58 +02:00
Giovanni
3c3ad48545
Ensure double and float uses the proper method to decode it. (#3105) 2022-10-18 17:02:59 +02:00
Dean
59b38e6efa
Add /*<type>*/ comments everywhere (#2986)
Adds /*<type>*/ comments and a linter check from rz-bindgen to enforce
their existence and consistency

Also includes the following fixes made when adding the annotations:
* removed unused intern_table arguments in pyc_dis.c, pyc_dis.h, asm_pyc.c
* removed unused classes argument from place_nodes in agraph.c
* removed unused recurse and recurse_bb functions in canalysis.c
* removed unused vars field from RzPrint struct
* removed unused RzAnalysisType* structs from rz_analysis.h
* removed unused list field from RzEgg struct
* fixed bug in bp_plugin.c where duplication-checking logic iterates over the wrong list
* removed unused q_regs field from RzDebug struct
* removed unused backtrace field from RzDebugPlugin struct
* removed unused classes_list field from RzBinNXOObj struct
* removed unused methods_list and classes_list fields from RzBinZimgObj struct
2022-09-11 13:04:53 +08:00
Khairul Azhar Kasmiran
06000072af
Fix gcc12 format.c -Wmaybe-uninitialized warnings (#3008) 2022-09-06 20:54:04 +08:00
Florian Märkl
4e5857cacf
Meson refactor: collect modules in dict and centralize config (#2945)
Duplicated code for pkg-config and cmake configuration is avoided by
letting every rizin module register itself in a global dictionary
called "modules" which is then iterated in one place to perform any
shared logic, inspired by how qemu handles multiple targets in its meson
build system.

This is an almost pure refactor, so the resulting .pc/.cmake files
should be identical with the following exceptions:
- rz_reg.pc does not have plugindir anymore as rz_reg has no plugins.
- Some other modules have their dependencies in .pc files altered to be
  consistent with cmake.
2022-08-20 19:59:27 +02:00
wingdeans
a6a7a5f530 Fix annotation inconsistencies 2022-08-03 00:29:56 -04:00
GustavoLCR
35cf52eb14
Fix double free of enum member name (#2817) 2022-07-19 09:20:29 +08:00
Riccardo Schirone
8939fdbd7d
Use add_global_arguments instead of passing cflags/ldflags all around (#2812)
See also 66a0e22293/docs/TESTING_WITH_SANITIZERS.md (clang)
2022-07-17 21:33:51 +08:00
Anton Kochkov
2188b4564d
Various Coverity fixes (#2615)
* Fix CID 392733 - memory leak

* Fix CID 392732 - memory leak

* Fix CID 392730 - memory leak

* Fix CID 392729 - memory leak

* Fix `rz_analysis_diff_free()` API function

* Fix CID 392685 - memory leak

* Fix CID 392012 - use after free

* Fix CID 391968 - uninitialized pointer read

* Fix CID 391966 - memory leak

* Fix CID 391964 - uninitialized pointer read

* Fix CID 390013 - memory leak

* Fix CID 389939 - memory leak

* Fix CID 379249 - memory leak

* Fix CID 378881 - uninitialized scalar variable

* Fix CID 378973 - uninitialized scalar variable

* Fix CID 378850 - uninitialized scalar variable

* Fix CID 371079 - memory leak

* Fix CID 367478 - memory leak

* Fix CID 366821 - memory leak

* Fix CID 366736 - memory leak

* Fix CID 361684 - uninitialized scalar value

* Fix CID 352581 - memory leak

* Fix CID 352557 - memory leak

* Fix CID 348937 - memory leak

* Fix CID 322229 - memory leak

* Fix CID 320122 - memory leak

* Fix CID 317611 - memory leak
2022-05-15 23:15:28 +08:00
Giovanni
423617930c
[dalvik] handle move-exception after gotos/returns and mid op jumps (#2603)
* Fix dalvik analysis by looking for move-exception after gotos/returns
* Fixed Dalvik analysis due compiler optimizations
2022-05-12 13:16:54 +02:00
Riccardo Schirone
ce6ac3e467 meson: use major/minor only in the lib soversion 2022-05-10 21:04:43 +02:00
Giovanni
0dcdc842a2
SDB usage cleanup within rz_bin 2022-05-10 10:27:33 +08:00
Anton Kochkov
b1e48a0c1c
Various Coverity fixes (#2499)
* Fix CID 390322 - memory leak
* Fix CID 390031 - memory leak
* Fix CID 390014 - memory leak
* Fix CID 389941 - memory leak
* Fix CID 389093 - memory leak
* Fix CID 389090 - memory leak
* Fix CID 379250 - memory leak
* Fix CID 378897 - unterminated string
* Fix CID 378854 - memory leak
* Fix CID 373736 - memory leak
* Fix CID 371126 - memory leak
* Fix CID 371089 - memory leak
2022-04-05 22:42:36 +02:00
Anton Kochkov
c860486ce1 Better error message for type redefinition 2022-04-04 15:31:55 +08:00
Riccardo Schirone
3fd578ef7a build: use run_command(..., check: false) as return code is used
run_command(..., check: true) was introduced because of a breaking
change in newer meson versions
(https://github.com/mesonbuild/meson/issues/9300), however Rizin uses
the return code to see if the subproject is in the right state or not.

Revert back to check: false, so that meson will not fail and we can
detect the failure in our meson.build files.

Signed-off-by: Riccardo Schirone <sirmy15@gmail.com>
2022-03-29 16:53:15 +02:00
Florian Märkl
1cbd1d7b31
Introduce addr_bits to type db for e.g. thumb (#2457)
This has the same meaning as rz_analysis_get_address_bits(), i.e. the
size of an address, which is often, but not always the same as the
"asm.bits" bitness, especiall in thumb where it has to be 32, rather
than 16. This fixes pointer size calculation for such cases.

Fix #1835
2022-03-27 15:53:42 +02:00
Riccardo Schirone
57a5ab5d0b Keep targeting meson 0.55 2022-03-25 17:43:56 +01:00
Riccardo Schirone
230652aa98
Add -Wimplicit-fallthrough to meson file (#2438) 2022-03-24 08:27:18 +08:00
Riccardo Schirone
cf56eda58d RzType: variadic argument is now a separate token in the grammar 2022-03-18 17:29:39 +01:00
Peiwei Hu
d7cb78879e
Add hint for unexpected type definition (#2393) 2022-03-14 10:46:59 +08:00
Peiwei Hu
a5cb17c4ed
Fix rz_type_cond_invert (issue 2265) (#2397) 2022-03-10 19:57:44 +08:00
Giovanni
bfec86a12e
Add option to install sigdb systemwise and custom user location for additional signatures (#2328) 2022-02-28 14:32:38 +01:00
GustavoLCR
4cf676f91a Add rz_type_base_type_kind_as_string() API 2022-02-25 13:17:20 +08:00
GustavoLCR
2704a00803 Implement rz_type_db_struct_member_offset() 2022-02-13 11:40:31 +08:00
GustavoLCR
a3abc76d5a Rename rz_type_db_struct_member_offset()->..._packed_offset() 2022-02-13 11:40:31 +08:00
Anton Kochkov
2f638cad1e Convert f commands to rzshell
* Changed behavior of `f` to only add flag if there is none
* Changed behavior of `f+` to add flag in any case
* Moved listing subcommands from `f` to `fl`
* Moved listing subcommands from `f.` to `f.l`
* Added subcommand `f.l*` to list all local flags in all functions
* Listing flags at the current offset became `fl.`
* Moved `f=` to `fl=`
* Old `fl` (flag length) now became `fL`
* Removed original `fe` commands
* Old `f?` (check if flag exists) now became `fe`
* Removed `fV` commands
* Removed `fn` commands in favor of `fl` and `asm.flags.real=true`
* Removed `fS` commands (`fSo` and `fSn`)
* `fo` became `fortune` and moved from "flags" to "shell" category
* Removed oldshell handlers of the `z` commands
2022-02-03 21:46:42 +08:00
Rot127
1409025ecf
Adapt basic block analysis for the Hexagon architecture. (#2073)
* Rebase onto branch 'dev' and resolve conflicts.
* Add tests for unmapped jumps.
* Fix test: Flags are correctly detected.
2022-01-05 16:51:44 +00:00
GustavoLCR
2e065789a7
Fix #1377 - Handle forward definitions in PDB parser 2022-01-05 18:38:02 +08:00
Anton Kochkov
89d61756c1
Fix self-referential typedef format (#2134) 2021-12-24 00:53:36 +08:00
Riccardo Schirone
6f40dfe493
Move remaining things from shlr/ to meson subprojects (#2126)
* Move binrz meson directives to binrz/ dir

* Move rizin-shell-parser to a subproject

* Move bochs to a meson subproject

* Move rzqnx to meson subproject

* Move winkd to a meson subproject

* Move rzar to a meson subproject

* Move rzw32dbg_wrap to a meson subproject

* Move ptrace-wrap to a meson subproject

* Move rzgdb to a meson subproject

* Rename w32dbg_wrap to rzw32dbg_wrap

* Update CODEOWNERS

* Remove old references to shlr

* Move shlr/heap stuff in core and remove shlr/arm

* Move spp to a meson subproject

* Remove last references to shlr

* Remove use_webui option

* Move include files directives to librz/include/meson.build

* Move librz meson directives into librz/meson.build

* Handle d/ directories inside the specific module meson.build

* Move plugins listing to specific module meson.build

* Move rzheap to its own subproject

* Fix js linter and licenses

* Use meson.override_dependency for all rz_ modules
2021-12-22 09:20:39 +08:00
Riccardo Schirone
47e1cb8335
Provide CMake config files for CMake projects (#2057)
* Remove wrong librz.pc.in file
* Add plugindir variable to .pc files to allow easy plugin configuration
* Add CMake config files to find Rizin in CMake projects
* Add CI jobs to check cmake files
* Provide workaround for mesonbuild/meson#9702
* Use .lib suffix and no prefix on MSVC to make CMake files work
* Disable cmake files on static libraries build
2021-12-17 09:16:25 +00:00
Dhruv Maroo
a255ff57a2
Fix some more Coverity issues (#2044)
* C352467: Free the heap allocated string after appending to `RzStrBuf`

* Remove unused variable `nofail`

* C352453: Free `fieldstr` after appending to `format`

* C350836: Free `name` before returning inside the loop

* C349252, C349231: Free `ta` when breaking halfway through the loop

* C349248: Free `pj` before breaking from switch statement

* C366622: Check result of `strtok` (`fcnname_aux`) for `NULL`

* Free `RzList` before returning from macro `SYNC_READ`

  * Fixes Coverity issues 366625, 366624, 366623, 366621 and probably
    a few others as well

* C366620: Check `arg` for `NULL` before dereferncing in `strchr`

* C366618: Cleanup `parse_lis` and use `rz_str_*` API instead of C `str` API

* Fix `SYNC_` macros in `cmd_regs.c` to no return prematurely

* C365952: Check `x` for `NULL` before dereferencing

* C365936: Use a wider integer type for the bitshift

* C365808: Fix double free of `real_type`

* C365805: Remove redundant `NULL` check for `path`
2021-12-13 23:09:46 +08:00
Riccardo Schirone
64469f2811
Changes in how paths are handled (#1997)
* Remove `RIZIN_EXTRAS` because useless

Extras plugin should be treated as any other regular plugin, they should
not have their own directory. I believe we did not have anyway any
plugin using that directory.

* Do not use `<version>` in `/usr/share`

Users can only install one version of Rizin at a time anyway, thus
splitting the `/usr/share/rizin` directories does not really bring
multi-version install possible. At the same time, we stick to what's
common for other tools, which do not use version in `/usr/share`

* Move plugin directory to `/usr/lib64/rizin/plugins`
* Remove `RZ_HOME_BIN` env var because not useful anymore
* Introduce `rz_util/rz_path` to provide rizin paths
* Use `rz_path_system_sdb_types` whenever it makes sense
* Use some others `rz_path_*` functions instead of custom ones
* Use `rz_path` APIs for themes, fortunes and signatures
* Remove `rz_sys_prefix`
* Reduce the number of defines needed to handle home and system paths
* Reduce the number of `rz_path` functions
* Make the lib debug depending on log level and `RZ_LOG_DEBUG`
* Refactor a bit how directory of plugins are loaded
* Keep supporting old plugins directory for at least 0.4.0
2021-11-30 13:36:38 +08:00
Dhruv Maroo
00c43df95d
Coverity scan fixes (mostly memory leaks) (#2037)
* Add `rz_goto_if_fail` macro
* Useful when one needs cleaning up before returning
* Coverity 364174: Free `alloc` before returning
* Coverity 364179: Return NULL before allocating ret to avoid memleak
* Coverity 364177: Return NULL before allocating ret to avoid memleak
* Coverity 364167: Free `ret` before returning prematurely
* Coverity 364165: Return NULL before allocating ret to avoid memleak
* Coverity 356612: Free list `dbg_maps_addrs` in the `err` goto
* Coverity 354023: Free `type` when cleaning up
* Cov. 352571, 352465: Goto `urnexit` so that `real_*` variables are freed
* C352564: Allocat `fmt` in every case, and free it before returning
* C352449, C352557, C352449: Don't leak `real_*` variables
2021-11-29 11:54:12 +08:00
Dhruv Maroo
34d345d884 Format according to clang-format-13 2021-11-25 15:44:28 +08:00
Peiwei Hu
3c2ad5abce
Fix: UAF caused by parse_type_abstract_declarator_node() (#2016)
Signed-off-by: Peiwei Hu <jlu.hpw@foxmail.com>
2021-11-24 08:32:36 +08:00
Khairul Azhar Kasmiran
906ece4211
Add asan build for clang (#1910) 2021-11-17 21:02:02 +08:00
Riccardo Schirone
589ab9299c Fix tests after more rigid wx 2021-11-09 12:01:41 +01:00
Florian Märkl
3e7cdf58ed Remove strnlen() calls and replace by rz_str_nlen() 2021-10-26 10:50:22 +02:00
Anton Kochkov
022c606372 Rename RzStrEncOptions to RzStrEscOptions 2021-10-16 11:33:48 +08:00
Anton Kochkov
39613b5c16
Port C (metainformation) commands to the rzshell (#1752)
* Do not escape strings during the search
* Port `C` (metainformation) commands to the rzshell
* Improve string autodetection
* Remove `Cr` and RZ_META_TYPE_RUN
* Escape `\x1b` as `\e` character in strings
* Move string encoding options to `RzStrEncOptions` struct
* Add `esc_double_quotes` option to `RzStrEncOptions`
* Do not filter out unprintable characters for uppercase check
* Use `esc_double_quotes` when printing the string between '"' in disasm
* Use signed chars on all platforms/architectures

Co-authored-by: Riccardo Schirone <sirmy15@gmail.com>
2021-10-15 16:48:18 +08:00
Dhruv Maroo
4f8100cd97
Extend the pretty printing API for base types and other printers (#1781)
* Replace `rz_type_db_base_type_as_string` with `rz_type_db_base_type_as_pretty_string`

 * Use the new type pretty printing API to pretty print base types

* Add option to return newline terminated string by pretty printing API

 * Add `RZ_TYPE_PRINT_END_NEWLINE` option to RzTypePrintOpts

* Improve printing in cases of empty structs/unions/enums

 * Initially, the separator was printed between the curly breaces
   irrespective of whether the struct/union/enum is empty. Now the
   separator is not printed if the given type is empty

* Add pretty printing support for typedefs

 * Also, add another type printing option to show typedefs. To be used in
   `rz_cores_types_typedef_as_c`

* Refactor `.*_as_c` functions to use the new type pretty printing API

* Add tests for typedef and `unknown_t` for pretty printing API

* Add `rz_type_db_base_type_as_string` back. Update tests.

 * Use ternary operator to make expression more concise

* Add doxygen documentation for `rz_type_db_base_type_as_string`

* Use `rz_vector_len` to determine if empty, instead of convoluted logic

* Remove redundant `RZ_NONNULL` for RzTypeDB

* Fix integration tests for type printing

* Update Doxygen documentation

* Fix failint enum printing itegration tests

* Fix according to clang-format
2021-10-02 13:51:01 +05:30
Anton Kochkov
458095d7a0
Fix afvd command for compound types (#1786) 2021-10-02 11:00:14 +08:00
Dhruv Maroo
178701f721
Reduce registers shown in the output of dr and Vpp when analysing an ARM64 executable (#1739)
* Add function to check if a register is a system register

* Only checks for ARM64 system registers as of now

* Check for system registers in ARM64 when printing registers using "dr"

* Does not completely remove the unnecessary register, but removes a
  huge number of useless registers printed by "dr"

* Rename `RZ_REG_TYPE_ALL` to `RZ_REG_TYPE_ANY`

* ADd register types for "sys" and "pauth": `RZ_REG_TYPE_SYS` and
  `RZ_REG_TYPE_PAUTH` respectively

* Remove `rz_reg_is_system_reg`

* Add `sys` and `pauth` register profiles

* Update debug tests to account for new arenas and register profiles

* REplace "pauth" with "sec" reg profile

* Update integration tests to account for new register profiles: `sys`, `sec`
2021-09-28 23:49:55 +08:00
Dhruv Maroo
63ccf386f2
Type pretty printing API (#1678)
* Reduce duplicate code and use a single printing API for all sorts of
  printing requirements
2021-09-27 17:30:35 +00:00
GustavoLCR
a7dd835235
Fix incompatible return type warnings (#1721) 2021-09-19 10:52:28 +08:00
Florian Märkl
65d567282b
Remove length restrictions in analysis classes and various serializations (#1718) 2021-09-18 16:48:14 +02:00
Florian Märkl
1e50bcfab2
Fix Leaks in Types string conversions 2021-09-16 21:52:48 +08:00
Florian Märkl
7b573c6b5b
Make cpu and in RzTypeTarget owned (#1695) 2021-09-15 16:34:28 +00:00
Anton Kochkov
34f7d44bfd Parse comments in types definitions 2021-09-13 20:42:31 +08:00