Skip to content

Fix #19873 - Detect MZ executables shorter than 0x3e bytes ##bin - #27337

Merged
trufae merged 1 commit into
radareorg:masterfrom
Thanatos9404:mz-tiny-header
Nov 4, 2026
Merged

trufae merged 1 commit into
radareorg:masterfrom
Thanatos9404:mz-tiny-header

Conversation

@Thanatos9404

Copy link
Copy Markdown
Contributor
  • Mark this if you consider it ready to merge
  • I've added tests (optional)
  • I wrote some lines in the book (optional)

Description

Fixes #19873. check() in bin_mz.c rejected every file of 0x3d bytes or less, because it read e_lfanew at 0x3c for the new exe header check. But a DOS MZ header is only 0x1c bytes, and wlink or OPTLINK write small executables without padding, like the 37-byte one in the issue, so they were not detected. -F mz already loaded them correctly.

check() now requires the 0x1c-byte header, and reads e_lfanew and checks for a new exe header only when the file is long enough to have one. The entry point check is unchanged, so a small file still has to point its entry inside itself. The other MZ-family plugins (pe, ne, le, te) reject files this small anyway.

Testing

  • New test/db/formats/mz/tiny: the 37-byte file from the issue (0x20-byte header, mov ax, 0x4c00; int 0x21). It checks bintype mz and the code at the entry. It fails on master.
  • All db/formats/mz, db/formats/pe, db/formats/le and db/formats/ne tests pass (442). sys/lint.py --all is clean.

…#bin

check() rejected any file shorter than e_lfanew at 0x3c, but a DOS MZ
header is only 0x1c bytes, so small unpadded executables from linkers
like wlink or OPTLINK were not detected. Require the 0x1c byte header,
and read e_lfanew only when the file is long enough for it.
@trufae
trufae merged commit 302877a into radareorg:master Nov 4, 2026
46 checks passed
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.

rabin2 -H does not show header of exe build with WatcomV2 wlink

2 participants