Skip to content

Conversation

@antonangeloff
Copy link
Contributor

@antonangeloff antonangeloff commented Dec 25, 2025

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 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).
  • 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

A couple of improvements for MZ binary format parsing:

  • Fix for an incorrect index calculation which cause some sections to end up with 0 size, and in certain cases leave most of a MZ file unmapped
  • The MZ file can request additional memory from the DOS loader (e_minalloc header field at offset 0xA) for uninitialized data and stack usage - in that case the bin plugin will map that as a new section (extra)
  • If the MZ haven't requested additional memory but the initial SS/SP points outside of the loaded image, then the bin plugin will still consider this as extra memory and create an extra section
  • Map overlay region as a separate section. This is a region located after the loaded image (i.e. end of file), which is ignored by the DOS loader, but can contain additional code or data that the application can map by itself dynamically

Test plan

Added a new binary and integration test that reproduce the section discovery issue.

The changes can be also tested manually with the binaries attached in the original issue

Closing issues

Closes #5576

@github-actions github-actions bot added the RzBin label Dec 25, 2025
@codecov
Copy link

codecov bot commented Dec 25, 2025

Codecov Report

❌ Patch coverage is 81.81818% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.77%. Comparing base (ca47373) to head (d4c95ef).
⚠️ Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
librz/bin/format/mz/mz.c 81.81% 2 Missing and 4 partials ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
librz/bin/format/mz/mz.c 58.01% <81.81%> (+2.59%) ⬆️

... and 14 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ca47373...d4c95ef. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@antonangeloff antonangeloff changed the title Fix DOS MZ parsing issue Improve MZ binary format parsing Dec 29, 2025
@notxvilka notxvilka merged commit 065a329 into rizinorg:dev Dec 30, 2025
47 checks passed
WRenchJr42 pushed a commit to WRenchJr42/rizin that referenced this pull request Jan 4, 2026
* Fix index calculation issue
* Map extra data and overlay as separate sections
* Add test for previous session discovery issue and for confirming correct overlay section content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failure to parse DOS MZ files from Intel

3 participants