Repository navigation
Conversation
- Replace the hardcoded 128-byte buffer in `hit()` with a dynamically sized one based on `ro->bsize - delta`, so long strings are no longer silently cut off. - Extract the duplicated ascii/wide string-copy loops into a single static helper, `extract_string_unified()`. - Fix a memory leak: the early returns for `exec_command` and `rizin_command` now go through a shared `cleanup:` label so the buffer is always freed. Closes rizinorg#6289
kisnner26
requested review from
Rot127,
b1llow,
kazarmy,
notxvilka,
ret2libc,
thestr4ng3r and
wargio
as code owners
September 22, 2026 03:12
Author
|
For context: I had a previous attempt at this issue (#6761) that used AI-generated code and was correctly closed for that. This PR is a rewrite from scratch — I worked through the buffer-sizing math, the leak fix via |
Rot127
requested changes
Oct 27, 2026
wargio
requested changes
Oct 27, 2026
wargio
left a comment
Member
There was a problem hiding this comment.
comments are not needed, and they are in spanish.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6289
Problem
rz-find -Ztruncates any string longer than 127 bytes because the outputbuffer is a fixed
char _str[128]on the stack. Long mangled C++ symbols(e.g. STL/Android NDK demangled names) get cut off mid-string with no
indication of truncation, and the three near-duplicate extraction loops in
hit()(plain string, wide string, non-showstr) had diverging boundschecks — the wide-string path in particular indexed
ro->buf[i]againsti < sizeof(_str)instead of the actual search buffer size, which is anout-of-bounds read when a hit lands close to the end of
ro->buf.Fix
extract_string_unified(): a single bounds-checked extractionroutine (dest cap, source cap, wide-mode flag, optional display cap)
that replaces the three duplicated loops.
hit()now allocatesstrwithmalloc()sized to the actual bytesavailable from
deltato the end of the search buffer, instead of afixed 128-byte stack buffer, and frees it through a single
cleanup:label on every return path.
Testing
-Zmode #6289:rz-find -Zoutput now matchesizzbyte-for-byte for the long mangled symbol that used to get cut at127 chars.
test/db/tools/rz_findusingtest/bins/elf/0pack, asserting the full untruncated string.rz-testpasses (pre-existing unrelated failures on this machine aredue to a missing system
magicDB and a dev-build version string, notthis change).