rizin icon indicating copy to clipboard operation
rizin copied to clipboard

Fix mz header parsing issue

Open 4rayaditya opened this issue 2 weeks ago • 3 comments

Your checklist for this pull request

  • [x] I've read the guidelines for contributing to this repository.
  • [x] I made sure to follow the project's coding style.
  • [ ] I've documented every RZ_API function and struct this PR changes.
  • [ ] I've added tests that prove my changes are effective (required for changes to RZ_API).
  • [ ] I've updated the Rizin book with the relevant information (if needed).
  • [x] 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

This PR fixes a bug in Rizin's DOS MZ binary format parser that prevented proper parsing of MZ files generated by Intel compilers.

Problem:

  • Rizin failed to parse DOS MZ files from Intel compilers (e.g., IC96.exe)
  • Files would open but fail to extract code sections, functions, and entrypoints
  • Error: "The entry point is outside the load module size"

Root Causes Identified:

  • Overly strict entrypoint validation - Rejected valid entrypoints outside calculated load_module_size
  • Poor segment detection - Relied heavily on relocations, failing for files without them
  • Rigid file size validation - Complete failure on malformed/truncated files
  • Missing safety checks - Potential crashes from null pointer dereferences

Test plan

  • Code compiles without errors
  • Existing MZ test suite should pass
  • The previously broken segments test should now work
  • Intel compiler files (IC96.exe, etc.) should now be analyzable

Closing issues

Fixes #5576

4rayaditya avatar Dec 09 '25 15:12 4rayaditya

Please don't remove the PR template.

Rot127 avatar Dec 09 '25 15:12 Rot127

Converted it to a draft for now. Please fix the tests and mark it ready for review once green.

Rot127 avatar Dec 10 '25 13:12 Rot127

It doesn't even compile! https://github.com/rizinorg/rizin/actions/runs/20128085000/job/57763204154?pr=5599#step:12:1974

notxvilka avatar Dec 11 '25 09:12 notxvilka

AI slop

notxvilka avatar Dec 20 '25 07:12 notxvilka