Skip to content

Fix buffer overflow in the ANSI boot.config redirect hook#106

Merged
ManlyMarco merged 2 commits into
NeighTools:masterfrom
HetCreep:fix/create-file-hook-narrow-overflow
Jun 22, 2026
Merged

Fix buffer overflow in the ANSI boot.config redirect hook#106
ManlyMarco merged 2 commits into
NeighTools:masterfrom
HetCreep:fix/create-file-hook-narrow-overflow

Conversation

@HetCreep

Copy link
Copy Markdown
Contributor

What

create_file_hook_narrow memcpy'd the boot.config override into the caller's lpFileName buffer, overflowing it when the override path is longer than the original — an out-of-bounds write into the game's memory.

Fix

Point actual_file_name at our own narrowed override buffer (mirroring the wide create_file_hook) and free it after the CreateFileA call, instead of writing into the caller's buffer.

Fixes #105

create_file_hook_narrow memcpy'd the override path into the caller's
lpFileName buffer, overflowing it when the override is longer than the
original path. Point actual_file_name at our own narrowed buffer (mirroring
create_file_hook) and free it after the CreateFileA call.
Comment thread src/windows/entrypoint.c Outdated
Comment on lines +118 to +120
// Point at our own override buffer (mirrors create_file_hook). The old
// memcpy wrote the override into the caller's lpFileName buffer, which
// overflows it whenever the override path is longer than the original.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments shouldn't reference replaced code and explain why it was changed, this should be in the commit or PR description instead. Code comments should exclusively refer to the current code and its behavior.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it can just be removed since it offers no insight into what the code is doing currently.

Suggested change
// Point at our own override buffer (mirrors create_file_hook). The old
// memcpy wrote the override into the caller's lpFileName buffer, which
// overflows it whenever the override path is longer than the original.

@ManlyMarco ManlyMarco merged commit 4a35613 into NeighTools:master Jun 22, 2026
4 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.

Buffer overflow in create_file_hook_narrow: override written into the caller lpFileName buffer

2 participants