Skip to content

Fix odd-length hex conversion crash - #3658

Open
atirna wants to merge 2 commits into
rizinorg:devfrom
atirna:fix/odd-hex-conversion
Open

Fix odd-length hex conversion crash#3658
atirna wants to merge 2 commits into
rizinorg:devfrom
atirna:fix/odd-hex-conversion

Conversation

@atirna

@atirna atirna commented Aug 15, 2026

Copy link
Copy Markdown

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 updated the documentation with the relevant information (if needed)
  • I've used AI tools to generate fully or partially these code changes and I'm sure the changes are not copyrighted by somebody else.

Detailed description

rz_hex_str2bin writes one byte for a trailing lone nibble and returns the byte count as a negative value. The old code only reserved hex.length() / 2 bytes, so a single nibble passed an unwritable zero-capacity buffer to Rizin and crashed in rz_hex_str2bin.

I resize the buffer to (length / 2) + 1 before conversion, then use the absolute return value as the final byte count. Odd inputs now keep the padded low nibble without writing past the buffer or passing a negative size to QByteArray::resize.

I used OpenAI Codex (GPT-5.6 Sol) to inspect the affected conversion path and help verify the change.

Test plan (required)

  • built the full Cutter target against the bundled Rizin submodule
  • before this change, hexStringToBytes("e") crashes with SIGBUS (exit 138)
  • after this change, empty input stays empty, 6162 returns 6162, e returns e0, and 61626 returns 616260
  • ran xcrun clang-format --dry-run --Werror -style=file src/core/Cutter.cpp

Closing issues

Closes #3641

Comment thread src/core/Cutter.cpp Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cutter crashes with 1 valid hexadecimal character in edit byte

2 participants