fix: Address local memory boundaries and buffer constraints - #184
Open
doomedraven wants to merge 5 commits into
Open
doomedraven wants to merge 5 commits into
doomedraven wants to merge 5 commits into
Conversation
Owner
|
I note this goes in the opposite direction to #153 and swaps a stack-based buffer for an allocation. |
Contributor
Author
|
will check in a bit |
Centralize the shared output buffer limit in `hooking.h` and harden exception/watchdog logging against overruns. This replaces unsafe `snprintf`/`strcat` patterns with bounded `_snprintf_s` calls, adds a NULL check after `malloc`, and guards all log appends so long stack traces and severe faults are truncated safely instead of corrupting memory.
- In unhook.c (_watchdog_thread): use stack-allocated buffer (char msg[1024]) instead of heap allocation, strictly adhering to the SBO pattern from PR kevoreilly#153 - In capemon.c (capemon_exception_handler): fix sizeof(msg) pointer underflow calculation by using explicit remaining buffer capacity with _snprintf_s and _TRUNCATE - Drop global WIDE_STRING_LIMIT definition from hooking.h
Contributor
Author
|
Good catch @kevoreilly. Refactored to preserve the stack-allocation / SBO pattern from #153:
|
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.
Resolves unsigned underflow allocations hitting snprintf routines and expands hardcoded local stack matrices breaking deep module hooking structures.