Repository navigation
Fix #19873 - Detect MZ executables shorter than 0x3e bytes ##bin - #27337
Merged
Merged
Conversation
…#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.
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.
Description
Fixes #19873.
check()inbin_mz.crejected every file of 0x3d bytes or less, because it reade_lfanewat 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 mzalready loaded them correctly.check()now requires the 0x1c-byte header, and readse_lfanewand 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
test/db/formats/mz/tiny: the 37-byte file from the issue (0x20-byte header,mov ax, 0x4c00; int 0x21). It checksbintype mzand the code at the entry. It fails on master.db/formats/mz,db/formats/pe,db/formats/leanddb/formats/netests pass (442).sys/lint.py --allis clean.