Kernel: GetModuleFileName of a title image into a null buffer #373
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!373
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/373/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@marquezinii on GitHub · 2026-11-24 02:43 UTC · original
marquezinii:fix/module-file-name-null-buffer→main· +29 −8 · 1 files · 1 commits · merged 2026-11-25 00:10 UTCGetModuleFileNameW/Afor a title image builtslice::from_raw_parts_mut(out, size)from the title's pointer. A slice may not start at null even when it is empty, so a size query likeGetModuleFileNameW(module, NULL, 0)was undefined behaviour; in a debug build it is a failed precondition check inside anextern "system"function, which aborts the process (0xc0000409).A null buffer is now treated as no buffer: nothing is written, the call returns 0 and sets
ERROR_INSUFFICIENT_BUFFER, which is whatcopy_truncatedalready does for an empty one.Tested: a new test asks for a title image's name with
(NULL, 0)through both functions. Before the change the test binary aborts with 0xc0000409; now both return 0 and the last error is 122.cargo test -p victory-hlepasses and clippy reports nothing new.This touches the two call sites only, not
copy_truncated, so it should not get in the way of #186.@jeremygold02 on GitHub · 2026-11-24 04:09 UTC · original
Thanks @marquezinii for this null-buffer fix. I tested head
c000581df2cf12aaadfe49025f9abba8b5993c8ewith:Result: 1 passed, 0 failed (86 filtered out). The regression test calls both
GetModuleFileNameWandGetModuleFileNameAfor a title image with(NULL, 0)and verifies the no-buffer error behavior, covering the path that previously formed a slice from a null pointer.