Commit graph

838 commits

Author SHA1 Message Date
Rot127
a1012b5305
Improve performance of rz_bv_set_from_Xt64() at least for the value 0. (#6147) 2026-04-04 12:01:44 +00:00
Khairul Azhar Kasmiran
815c86a8f7
Inline rz_list_iter_set_data() and shorten it to rz_list_set_val() (#6131) 2026-04-02 06:04:54 +08:00
NOT XVilka
e26ed3a0ff
librz/util: remove unused rz_range functions (#6083)
Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2026-03-24 16:44:22 +08:00
Giovanni
70fdd67278
Allow rizin tools to run as standalone binaries (#6011)
* Implement TOOL/ENVS/EXIT_STATUS for rz-test

* update readme
2026-03-11 16:24:23 +00:00
Khairul Azhar Kasmiran
690daa2f54
ht_inc: Rename slots to slots_ (#6021) 2026-03-10 22:33:12 +08:00
Anton Angelov
95f94ae258
refactor: SwissTable implementation for ht (#5860)
* Add ht benchmarks
* Initial implementation
* Finalize native per-group lookup support
* Lookup SSE2 implementation
* Improve hashing
* Add support for custom elem_size
* Avoid double h2 hashing when reserving slot
* Make custom elem_size support conditional
* Fix issues with bitwise and default lookup implementations
* Implement deletion trick optimization
* Track growth_size instead of deleted_slots
* Refactor SDB to access ht via API instead of internals
* Modify SDB tests which rely on hashtable order
* Fix SDB build warnings
* Fix bug with finding next power of two
* foreach_kv to return a bool result
* Change SDB diff order expected by serialize_analysis unit test
* Fix bug in the bitwise lookup implementation
* Remove second call to rz_core_init() which causes memory leaks
* Update some regression tests to accept reordered output
* Adapt ht clear to new implementation
* Use fini_kv_pair and fix 1 potential leak on malloc failure
* Fix cmd/types test after merge
* Avoid second call to calsize_key and avoid iter leaks on malloc failure
* Improve hash distribution
* Extend benchmark suite
* Fix bug with string hashing
* Branchless write to mirrored ctrl bytes
* Simplify string hash and remove potential UB
* Move RZ_PREFETCH macro to rz_types.h
* Add SSE2 discovery in Meson
* Forward SDB string hash function to ht string hash
* Try to revert test_cpu_profiles() to avoid relying on a baked SDB file
* Revert SDB/CDB hash function change
* Fix SDB reference to HT hash function instead of CDB hash
* Change calloc to malloc
* Avoid storing/checking key_len and key_value if they are ut64
* Improve string hash function
* Rename default hash functions
* Improve bench code
* linter.yml: set clang-path to point to llvm-18
2026-03-02 12:31:35 +08:00
Ehab-24
492addb3a1
Enc: add unicode case mappings (#5956) 2026-03-01 15:06:28 +00:00
Thomas Strömberg
a65be1e6cd
Fix Illumos/Solaris platform support (#5972) 2026-02-27 13:01:40 +08:00
Rot127
d7111d056c
librz/util: add rz_vector_contains() and rz_vector_insert_sorted() (#5892)
* Add rz_vector_contains().
* Add rz_vector_insert_sorted().
* Pointer arithmetic fix for Windows.
2026-02-11 02:45:12 +08:00
Rot127
6a8d2ecf57
Check for empty vector to prevent OOB reads and writes. (#5591)
* Check for empty vector to prevent OOB reads and writes.

* Add tests to check for OOB reads/writes.
2026-02-10 16:57:12 +00:00
Khairul Azhar Kasmiran
2d49628aee
Remove rz_list_iter_get_data() (#5900)
* Remove rz_list_iter_get_data()
* Use rz_list_val() instead of rz_list_iter_get_data()
2026-02-10 22:03:37 +08:00
Giovanni
dfdd062f14
Rewrite of zImage bin parser & new structured data methods (#5893) 2026-02-09 19:00:42 +08:00
Rot127
dcb4acf661
Rename clean -> clear to match common API names. (#5891) 2026-02-08 15:03:52 +00:00
Rot127
0d5e300874
librz/util: add clean() function to hash tables and sets. (#5889) 2026-02-08 14:42:48 +08:00
Rot127
aaf9588c44
Constify rz_set_u/s_contains() (#5888) 2026-02-08 14:40:14 +08:00
Anton Angelov
067e319bac
Use ht_xx_size() instead of reading ht internal state (#5885) 2026-02-07 16:17:18 +00:00
Khairul Azhar Kasmiran
0e6b255519
Remove deprecated rz_list_get_next() (#5879) 2026-02-06 21:57:33 +08:00
Anton Angelov
0ff186d8e2
Improve performance of mem.c::read_n_bits() (#5819)
* Add micro benchmark
* Add implementation for rz_bv_set_from_buffer_*()
* Implementation for BE host
* Fix incorrect size parameter when calling rz_bv_set_from_buffer
* Warning when reading beyond ST64_MAX
2026-01-26 12:19:21 +08:00
Rot127
65ef6e3ed9
Fix return type description. (#5838) 2026-01-25 13:11:11 +00:00
Rot127
4675f5cafe
Add getter for the current log level. (#5807)
The getter is useful if a module outputs debug logs buts also some updated status update in a single line with rz_cons_printf("\r...").
The status update should not happen if the log level is below warning.
2026-01-23 18:52:45 +00:00
Khairul Azhar Kasmiran
d9f41e8074
Shorten rz_list_iter_has_prev/next() to rz_list_has_prev/next() (#5822)
* Shorten rz_list_iter_has_prev() to rz_list_has_prev()

* Shorten rz_list_iter_has_next() to rz_list_has_next()
2026-01-21 13:53:43 +00:00
Florian Märkl
c594b413ff
Swap argument order of rz_bv_copy* (#5793)
This brings these copy functions in line with the more common order of
dst, src as used in memcpy and rz_bv_*_inplace functions.
This is a breaking change and callers of rz_bv_copy() and
rz_bv_copy_nbits() must adjust to the new order.
2026-01-14 23:18:34 +08:00
Anton Angelov
602781b2dc
Implement rz_sys_backtrace() for Windows/MSVC (#5784)
* Implement rz_sys_backtrace for Windows/MSVC
* Add dbghelp.lib to dependency list
2026-01-13 00:55:20 +08:00
Giovanni
141f05b126
Remove rz_io_read_at and use only rz_io_read_at_mapped (#5777) 2026-01-11 22:50:50 +08:00
Anton Angelov
b2fb8bbec5
Improve performance of rz_bv_add_inplace() (#5751)
* Add rz_bv_add_inplace benchmark for 256-bit vectors

* Improve performance of rz_bv_add

* Simplify helper function and fix bug

* Minor changes
2026-01-11 00:14:19 +00:00
Giovanni
6926b6a65d
Rewrite C compiler code for rz-gg (#5761) 2026-01-10 13:36:51 +08:00
Khairul Azhar Kasmiran
e4ed1d3436
Fix "exeeds" typo (#5760) 2026-01-09 21:26:26 +08:00
Rot127
960dc17b23
util/bitvector: return successfully for bit vector shift of 0. (#5747)
The result of shift with 0 is perfectly well defined.
2026-01-08 23:27:38 +08:00
Rot127
4213ddfecc
Fix reachable invalid state, for bitvector in-place casts from large to large. (#5746) 2026-01-08 13:47:53 +00:00
Maijin
797fcd0ff6
test: increase coverage for RzCons and its components (#5735)
- Added tests for Cons Canvas, Histogram, HUD, Pal, Pager, Pipe, RGB, HTML, Line.
- Fixed rz_str_ansi_filter null terminator bug.
- Refactored test_cons.c by splitting it into smaller files.
- Improved many existing assertions to verify actual output content.
- Restored mu_assert_notnull checks for better reliability.

Co-authored-by: Maijin <maijin21@gmail.com>
2026-01-07 12:27:45 +08:00
Rot127
a89bbe5cf2
librz/util: implement inplace rz_bv_div and rz_bv_mod. (#5742) 2026-01-07 12:26:06 +08:00
Giovanni
ea21a4a7b4
Implement colors for tables and move RzListInfo out of table.c (#5729) 2026-01-05 21:34:41 +08:00
Khairul Azhar Kasmiran
37d2e2ff41
Readd deprecated rz_list_get_next() for rz-bindgen (#5718) 2026-01-01 23:54:53 +08:00
Khairul Azhar Kasmiran
ca47373fb7
Shorten rz_list_safe_prev/next to rz_list_prev/next (#5710) 2025-12-30 22:03:11 +08:00
SSharshunov
b4160d8050
New function rz_pvector_uniq (#5705) 2025-12-30 21:07:45 +08:00
SSharshunov
fb4822d658
librz/util: new function rz_pvector_find_index (#5700) 2025-12-30 03:33:54 +08:00
Arya H R
a6edb4ecc5
Fix various Coverity findings (#5668) 2025-12-30 02:02:56 +08:00
Khairul Azhar Kasmiran
2eac3fce25
Use macro versions of rz_list_iter_get_prev/next() instead (#5696)
* Add rz_list_safe_prev/next macros
* Remove rz_list_iter_get_prev/next() functions
* Use rz_list_safe_prev() macro instead of rz_list_iter_get_prev() function
* Use rz_list_safe_next() macro instead of rz_list_iter_get_next() function
2025-12-28 21:05:49 +08:00
Khairul Azhar Kasmiran
bd29b70793
Touch up rz_list_find() doc (#5693) 2025-12-27 22:38:52 +08:00
Giovanni
5ef76f42b8
Fix small mistake on x509 structure. (#5690)
* Fix small mistake on x509 structure.
* Add test with ed25519 certificate
2025-12-27 19:00:27 +08:00
Khairul Azhar Kasmiran
edfe7d3380
rz_list_contains: Return bool instead of iter (#5692) 2025-12-27 18:59:36 +08:00
Khairul Azhar Kasmiran
c93841de48
Remove rz_list_split() and rz_list_split_iter() (#5678)
* Remove rz_list_split() and rz_list_split_iter()
* Add RZ_OWN tag to rz_list_delete()
2025-12-26 22:32:24 +08:00
Khairul Azhar Kasmiran
c1fc1419e4
Rename some rz_list funcs to rz_list_XXX_val (part 1) (#5671)
* Rename rz_list_find_ptr() to rz_list_find_val()
* Rename rz_list_delete_data() to rz_list_delete_val()
2025-12-25 22:01:49 +08:00
Rot127
472819aa92
librz/util: add in-place bitvector operations (#5569)
* Add an in-place addition of bitvectors.

* Decouple _elem_len from assumption it has just enough bytes to hold len in bits.

* Add in-place copy of bits.

* Use default copy bits bitvector function.

* Mark stack allocated bit vector.

* Add inplace variant of complement_1

* Implement inplace bitvecotr not.

* Add inplace variant of rz_bv_and

* Implement inplace variant of rz_bv_or

* Implement inplace variant of rz_bv_xor

* Constify rz_bv_lsb/msb

* Implement inplace variant of rz_bv_neg

* Fix inplace add. Add inplace SUB

* Remove prefix

* Remove invalid const

* Implement in-place casting of bit vectors.

* Add a hash test

* Fix unnecessary &

* Prevent OOB reads & writes by copying only the minimum of bytes.

* Add inplace MUL

* Add ble version for bitvector set/get with bytes.

* Add documentation for inplace bitvector functions.

* Add bench of add/sub() and sub/add_inplace().

* Remove rz_bv_copy_nbits_inplace because it was the same as rz_bv_copy_nbits.
2025-12-23 13:56:06 +08:00
Giovanni
99c1a22d69
Extend ASN.1/PKCS7/X.509 to dump structures (#5656) 2025-12-22 09:41:56 +08:00
Peiwei Hu
8ca45d1ea5
Fix the missing release of RZ_OWN parameters (#5641) 2025-12-21 13:48:48 +08:00
Khairul Azhar Kasmiran
b96202ad48
Rename rz_list_first() / rz_list_last() to rz_list_first_val() / rz_list_last_val() (#5654) 2025-12-20 17:08:59 +08:00
Giovanni
f2f26b4466
Add pF8 for decoding PKCS8 & add info on /cm (#5647) 2025-12-20 16:28:10 +08:00
Giovanni
0a0e6c0b88
Optimize queue to act also as proper channel (#5627) 2025-12-20 00:40:13 +08:00
Khairul Azhar Kasmiran
981780600e
Rename rz_str_len_utf8_ansi() to rz_str_utf8_ansi_cols() (#5649) 2025-12-19 23:01:24 +08:00
Khairul Azhar Kasmiran
f32b7cda01
rz_str_utf8_cols: Add human emoji to TODO list (#5630) 2025-12-17 23:17:24 +08:00
Khairul Azhar Kasmiran
1cdb88be5a
Rename rz_str_len_utf8() to rz_str_utf8_cols() (#5626)
* Rename rz_str_len_utf8() to rz_str_utf8_cols()
* Rename utf8strlen0() to utf8strcols0()
2025-12-16 20:09:39 +08:00
Giovanni
69e0914237
Convert opex to use RzStructuredData (#5613) 2025-12-16 15:21:44 +08:00
Khairul Azhar Kasmiran
748f849dcf
netbsd /z??: Fix wrap point for utf8 word '"и.{3}м"' when scr.columns=70 (#5608) 2025-12-11 21:51:51 +08:00
Muhammed Answar C K
d3087cc148
shell: pipe support for uniq and sort commands (#5580) 2025-12-10 19:09:30 +08:00
Arya H R
2a02208740
shell: new arg type RZ_CMD_ARG_TYPE_FOLDER (#5514)
* Added new arg type RZ_CMD_ARG_TYPE_FOLDER
* Path normalization API
* Add tests
2025-12-10 19:08:38 +08:00
Rot127
65040bb7ae
Add helper to check if a thread terminated. (#5583) 2025-12-08 04:37:01 +08:00
Anton Angelov
0a14a7a1da
Improve performance of rz_bv_set_range() (#5562)
* Add microbenchmarks

* New implementation for rz_bv_set_range()

* Remove rz_ prefix from static function names
2025-12-04 14:44:19 +08:00
Anton Angelov
9d3109888e
Enhance performance of rz_bv_copy_nbits for large to small and small to large bv copies (#5551)
* Implement optimized functions for small to large and large to small

* Add benchmark instructions in testREADME.md

* Use the term unaligned consistently instead of nonaligned

* Slightly improve bitvector test error message

* Remove unnecessary annotations

* Edit readme

* Add explicit fallthrough comments

* Return statement for rz_bv_toggle_all()

* Extend tests
2025-11-30 00:48:36 +08:00
Anton Angelov
c186f1ec83
Enhance performance of rz_bv_copy_nbits (#5541)
* Add benchmark for rz_bv_copy_nbits
* Improve performance for large to large and small to small bitvector copy
* Fix bug with nbit=64 and simplify code
* Add test for same bitvector copy
* Move bit copy logic to separate function in rz_bits.h + improve comments
* Support same vector copy for unaligned case
* Expect non-null RzTable in bench utils and add comments
* Test against reference implementation instead of hardcoded values
2025-11-23 21:52:23 +08:00
Khairul Azhar Kasmiran
4cbba6a263
rz_str_trim_tail: Declare RZ_INOUT on both parameter and return value (#5546) 2025-11-23 02:04:35 +08:00
Khairul Azhar Kasmiran
5a1e6e1918
str_split_list_common_regex: Remove erroneous string termination (#5537) 2025-11-21 11:41:44 +08:00
Rot127
856c28f1e8
Fix several leaks. (#5536) 2025-11-19 23:22:56 +08:00
SSharshunov
5b43b91b78
refactor: resolve some memory leaks in util and search 2025-11-13 23:11:10 +08:00
Rot127
8197025e2f
Update contact information of Rot127. (#5522) 2025-11-10 17:15:15 +00:00
Ayush Goyal
a9fc5d3ca6
Fix: asn and asr command #3885 (#5477) 2025-11-04 23:38:16 +08:00
Giovanni
f0c572c325
Fix CSV output (#5495) 2025-11-02 11:35:43 +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
Rot127
d79ff51157
librz/bin: define string search parameters in plugins (#5406)
* Clarify docs of raw_alignment

* Set Go and Rust string encoding for binary string search.

* Add detailed doxygen about string search in bin plugins.

* Add the number string code points as detail to string search hits.

* Add helper to check if string encoding needs scanning.

* Add helper to generate a string wildcard pattern.

The pattern is supposed to match any human readable string.
Before the string search refactor there was no explicit definition
what characters mark the end of a string and which ones don't.

This pattern should match strings of the old interpretation.

* Enable the RzBin plugin to search strings with direct matching instead of scanning.

This significantly speeds up the string search when a binary is opened.
The prerequisite is that the plugin specifies the string encoding.

* Enforce UTF-8 for initial string search.

* Add custom string search for PE files.

* Clean up and document rz_utf8_encode

* Don't demote explicit UTF-8 encoding to ASCII.

* Increase min JIT stack size due to not reproducable search results.

* Simplify wildcard regex pattern.
2025-10-08 10:02:32 +08:00
Rot127
92eff78276
librz/util: UTF-16/32 to UTF-8 conversion (#5431)
* Replace rz_str_utf16_to_utf8 with one matching the other string convert functions.
* Add rz_str_utf32_to_utf8
2025-10-05 19:16:53 +08:00
Rot127
47d2fb1911
librz/util: remove const qualifier from buffer. The ownership is transferred. (#5433) 2025-10-05 14:42:10 +08:00
Rot127
f8c4f38fa1
Add DOTALL flag to regex. (#5434) 2025-10-05 14:41:28 +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
93af16ea15
rz_vector_insert_range: If count is 0, bypass rz_vector_index_ptr() in returning insert addr (#5425)
* rz_vector_insert_range: If count is 0, bypass rz_vector_index_ptr() in returning insert addr
* Add documentation to rz_vector_insert_range
2025-10-01 22:04:05 +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
Rot127
41bbed1883
Fix and extend string search integration tests (#5393)
* Remove unused declaration.

* Fix integration test to have a real scan example.

This also fixes a bug that the last NUL/invalid byte in a string
was not included in the UTF-8 bytes -> memory offset map.
2025-09-18 22:54:23 +08:00
Rot127
2d7b178c84
String search performance improvement (#5383)
* Add speed up search for unaligned buffers and string encodings.

The new search mode adjusts the buffer's data (swap endianness, fix alignment)
so the buffer can be searched with PCRE2 without scanning.

It also enables RzRegexMulti opbjects to have their own JIT stack.
This makes them usable in a thread safe manner.

* Fix regex compilation on big endian systems

* Update the scanning check (UTF needs no scanning anymore).
2025-09-18 00:42:03 +08:00
Rot127
9705b44f6e
Enable string search collection to search for multiple encodings. (#5378)
* Enable string search collection to search for multiple encodings.

This moves the encoding and alignment properties out of the collection
object into the RzDetectedStr object.
It essentially removes duplicates of this info.

Because of this move, rz_search_collection_string_add() will now
check for invalid collection configurations.

* Rename type -> encoding
2025-09-17 10:54:31 +08:00
Rot127
fdc9ecbacc
Add several memory helpers (required for speed up of string search). (#5372)
* Add function to memcpy memory with offset.

* Add count trailing zeros function.

* Add function to determine pointer alignment.

* Add helper to swap sequences of 2 bytes.

* Add helper to swap sequences of 4 bytes.

* Print pointer in warning

* Fix tests

* Use uintptr_t type to prevent undefined behavior.

* Remove alignment requirement and rely on malloc promises.

* Add in place byte swap functions.

* Move the endianness swapping into util/rz_endian

* Use GNU builtin __builtin_ctzll/clzll.

Also fixes the include guards of __builtin_clzll
and handles the undefined case of x == 0 of it.

* Add doxygen
2025-09-17 00:07:44 +08:00
Rot127
517520cdef
librz/search: address Coverity issues. (#5371) 2025-09-14 21:56:04 +08:00
Rot127
a59b090db9
String search integration tests (#5358)
* Add integration test for a simple string search.
* Clean up rz_str_is_false
* Doxygen
* Add rz_buf_type
* Sort search hits not just by address but also by size.
* Add a paranoid regex Hindi test.
* Add an integration test using RzCore and searching for UTF-16LE.
* Revert "Temporarily remove codecov workflow due to https://github.com/codecov/codecov-action/issues/1877 (#5366)"

This reverts commit dc5d50ce58.
2025-09-14 11:44:14 +08:00
Rot127
c73fb92670
librz/search: rename r variable to ucp for clarity. (#5364)
`r` was short for rune, which was not properly defined term.
Using `ucp` for Unicode code point makes more sense.
2025-09-12 11:48:17 +08:00
Rot127
f4e1118bc2
Remove Base64 from character encodings enum. (#5362)
Base64 is not a character encoding but a binary to text encoding method.
2025-09-12 11:46:13 +08:00
Rot127
699c7d2dff
Improve performance of string search. (#5262)
* Make checks against defined Unicode points optional

* Allow to decode UTF-16 without writing the result.

* Remove PCRE2_NO_UTF_CHECK as default, since it can lead to undefined behavior.

* First refactor regex to support utf16 and utf32

* Add UTF-16-BE encoding function

* Add UTF-8 counting helper functions.

- One for counting the number of Unicode code points.
- The other to get the number of bytes required to represent the given UTF-8 string in UTF-16.

* Remove unused code

* Add UTF-8 to UTF-16 conversion function.

* Add type annotations

* Implement utf8 to utf32 string conversion

* Add UTF-16/32 versions of all other necessary regex functions for str search.

* Another regex refactor for utf16/32

* Add UTF16/32 regex matching tests.

* Implement still segfaulting (possibly JIT double usage) regex search.

* Duplicate match_first functions to reduce necessary branch predictions.

* Reduce number of required branches for encoding UTF16/32 to one.

* Duplicate match_all_internal functions to reduce necessary branch predictions.

* Fix too early free

* Only allocate match vector when needed.

* Fix: use code point size of buffer.

* Add missing return

* Normalize pointers to UTF16/32 strings to use proper code point with

* Also replace spaces with in utf16/32

* Add an additional host endian tests for UTF16/32 string encodings.

* Ensure thread savety.

JIT compiled patterns need to be owned by a single thread.
For the search we need to clone it.

JIT matching structures are optionally cloned as well.

* Enforce NO_UTF_CHECK in regex search.

This improves performance and currently is
default because we always match on binary data.

* Fix matching of UTF strings which are not suported by direct buffer matching.

PCRE2 only supports matching against memory which is aligned
to a code point width of the encoding.

These changes prevent taking the fast (direct matching with PCRE2) path
and use the slow string search path if the alignment doesn't match
the UTF string encoding.

To not complicate the change and additional alignment member
is added to each searched string in the search collection.

* Create search hit description on the stack

* Unset complete JIT matching if user provided custom jflags.

* Document what passing NULL to copy function pointers does.

* Replace the retarded idea of tracking offsets with a hashmap with a linear buffer.

This improves performance something like 10x.

* Remove const for the non-JIT builds.

* Remove additional flags for skip checking.

It is not needed because each decoded character is checked for printablity below anyways.

* Enfore no setup of IO mem with 0xff

* Fix: Set JIT complete flag for multi regex patterns

* Fix heap.

* Add note about worsed performance path.

* Fix unit test with string terminated by undefined code point.

* Run clang-format

* Fix order of arguments

* Add warning about string search with encoding=guess to tests.

* Fix string lengths, they no longer count the final invalid code point.

* Fix endian macro on Windows

* Fix NULL dereference

* Fix number tests

* Use endianness check not dependent on stdbit

* Fix type annotations.

* Reintroduce rz_str_len_utf8char

* Fix command description.

* Fix and unify RZ_SYS_ENDIAN macros.

- Don't allow unhandled architectures anymore.
- Check endianness for Sparc and PPC using non GCC/Clang compilers.
- Fix several endianness checks using the value instead of the macros.

* Fix tests

* Apply review comments.
2025-09-11 22:29:20 +08:00
Ahmed Kamal
4fd6b9c2da
Update libmagic to openbsd/src@0e59d0d (#5288)
* Update magic implementation from openbsd to 0e59d0d commit
* Various refactoring of the original code to use RzUtil primitives instead of the custom implementation
* Remove static variables from the original code
* Remove Queue, regex_t and use RzList, RzRegex instead
* Remove unneeded code from the original implementation
* Use RZ_LOG_* macroses instead of the custom logging of the original code
* Use rz_endian primitives where appropriate
* Use os-specific functions where appropriate
* Move magic functions to internal header
2025-08-26 12:06:54 +08:00
Nir Lichtman
faf3c53168
librz/util/subprocess: fix inability to automatically run .com executables (#5312) 2025-08-25 12:20:37 +08:00
Ahmed Kamal
f15589d3cf
Add rz_str_ncat (#5307) 2025-08-24 21:10:19 +08:00
Giovanni
9db7089248
Change output of iH to support structured data. (#5263) 2025-08-23 22:23:14 +08:00
Rot127
8cae918f01 Add a helper function to spread value bits according to mask. 2025-08-20 22:31:02 +08:00
Ahmed Mohamed Ibrahim
38a530dbe3
librz/util: base64, base85, base36, base32, base16 support and refactor (#5216) (#5271)
* Rename librz/util/ubase64.c into librz/util/base64.c for consistency #5216

* Add Doxygen documentation to function in librz/util/base85.c #5216

* Add unit-tests for librz/util/base85.c #5216

* Refactor base85 API and internal functions #5216

base85 was using a FILE as an input and it used to print its result to
STDOUT, which was very bad for having unit-testing or to use it to
extend rz-hash functionality, since the solution I really had was
through using pipes which isn't ideal as much as the refactoring one.

* Extend rz-hash with base85 #5126

* Fix formatting #5216

* Extract base36 decoding function from subprojects/rzwinkd/iob_net.c to librz/util/base36.c #5216

- Also, added Doxygen docs to rz_base36_decode function

* Added rz_base36_encode_dyn #5216

- this function encode a u64 value to it's char[13+1] base36 counterpart
- later, it will be helpful in expanding the funcitionality of rz-hash
- added its Doxygen docs

* Expand rz-hash with base36 encoding/decoding #5216

* Refactor rz_base36_decode to return a suitable error code like -1 #5216

- that should help testing it later for valid and invalid decodings
- keeping the original behaviour as it was in
subprojects/rzwinkd/iob_net.c

* Add unit-tests for base36 encoding & decoding functions #5216

* Fix formatting #5216

* Fix base36.h header file guards #5216

* Add base32 encoding & decoding #5216

added their Doxygen Docs as well

* Add base32 encoding and decoding unti-tests #5216

* Expand rz-hash with base32 encoding/decoding functionality #5216

* Fix formatting #5216

* Fix add base32 to codec_name_bytes #5216

* Fix base32 docs #5216

* Add base16 encoding/decoding functions #5216

- added their Doxygen docs as well.

* Add base16 unit-tests #5216

* Fix test_base85 conversions warnings #5216

* Expand rz-hash with base16 encoding/decoding functionality #5216

* Fix formatting #5216

* Fix doxygen docs #5216

* Restore subprojects/rizin-shell-parser/parser.c to match origin/dev

* Fix the order by baseXX

* Fix base16 - invert the logic in calculate_src_length

* Fix base16 - intialize variables in rz_base16_encode

* Fix base16 - null terminate the output buffer of rz_base16_encode_dyn

* Fix base16 - get rid of unnecessary else in rz_base16_decode

* Fix base16 - use `len & 1` instead of `(len % 2) != 0`

* Fix base32 - invert the logic in calculate_src_length

* Fix base32 - compress two return statments by using `rz_return_val_if_fail(src && dest, 0);`

* Fix base32 - null terminate the output of rz_base32_encode

* Fix base32 - get rid of unnecessary else in rz_base32_decode

add more parentheses to split addition from mult for better clarity

* Fix base32 - intialize variables in rz_base32_encode_dyn

* Fix base36 - intialize `tmp` variable in rz_base36_encode_dyn

* Fix base36 - use RZ_LOG_ERROR instead of eprintf

* Fix base36 - use RZ_NULLABLE for the API interface

* Fix base85 - use RZ_OUT & RZ_NULLABLE for the API interface

* Fix base85 - use RZ_LOG_ERROR instead of eprintf

* Fix base85 - use size_t instead of int for decode_tuple_buf

* Fix base85 - remove unused varaible, `out_len`, in rz_base85_encode_dyn

* Fix base85 - correct decode buffer size calculation

The previous rz_base85_dec_buflen() underestimated the worst‑case output
size (3 bytes per 4 input chars), causing overflows when using ‘z’/’y’
abbreviations. Update it to allocate 4 bytes per input character plus
one for the NUL terminator, eliminating heap-buffer-overflow errors.

* Fix formatting

* Fix base85-test - use `newlines` variable to make sure line breaks were inserted as expected

* Fix base85-test - remove unnecessary includes

* Fix rz-hash test - updated rz-hash -L expected result

* Fix crypto_base36 - use RZ_LOG_ERROR instead of eprintf

* Fix base16 - compress rz_return_val_if_fail statements and move before locals

* Update base16 - use hex.c existing encoding/decoding logic

- base16.c encoding/decoding functions are now wrappers for hex.c
  `rz_hex_bin2str` and `rz_hex_str2bin` functions
- updated related base16 unit testing and documentation
- updated the integraion with rz-hash binary (or crypto_base16)

* Fix formatting

* Add documentation to rz_hex_bin2str

* Fix base85 - add missing `reutrn` docs to rz_base85_encode function

* Fix base85 - use RZ_NONNULL for dest and src function instead of RZ_NULLABLE

* Fix base36 - use RZ_NONNULL for dest and src function instead of RZ_NULLABLE

* Fix base16 - use RZ_NONNULL for dest and src function instead of RZ_NULLABLE

* Fix base32 - use RZ_NONNULL for dest and src function instead of RZ_NULLABLE

* Fix base16 - add missig checks for invalid inputs in rz_base16_encode & rz_base16_encode_dyn

* Fix base32 - add missing checks for bad encoding

* Fix - add missing SPDX

* Fix Formatting

* Add rz_base36_encode & rz_base36_decode_dyn functions to base36 API
2025-08-17 15:26:25 +08:00
Rot127
25d500a86b
librz/util/float: fix cast of negative zero to integer. (#5291) 2025-08-06 00:06:43 +08:00
Ahmed Kamal
ed7681b9c1
Remove global variables from sdb/main.c (#5284)
* Remove static varaibles from sdb/main.c

* Remove Signal handling

* Remove unneeded header

* Add annotations

* Fix

* Convert allocation from heap to stack

* Initialize struct
2025-07-23 19:17:25 +00:00
Rot127
22089ed1bb
Fix runtime check for float128 values. (#5283) 2025-07-21 08:28:52 +08:00
Rot127
15e051598f
Enable initialization of negative zero and add float neg tests. (#5282)
* Enable initialization of negative zero and add float neg tests.
* Use argument instead of another function to init negative zero.
* Use platform agnostic negative inifinity value.
2025-07-21 08:28:32 +08:00
Ahmed Kamal
8ead5a4987
Remove static buf from sdb_lock_file (#5278) 2025-07-20 21:38:05 +08:00
Ahmed Kamal
f020764aef
refactor: remove sdb_fmt() and replace it with rz_strf() (#5276)
* Remove `sdb_fmt()` and replace with `rz_strf()`
* Use `strbuf_append()` instead of `out_concat()`
2025-07-18 22:07:23 +08:00
NOT XVilka
4d15e5245c
Remove unused rz_sys_cmdbg() function (#5268)
Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
2025-07-14 17:57:07 +00:00