XDXR-STREAM-RECORD-BOUNDS: require complete 16-byte StreamRecords in find_stream_record #484
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!484
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/484/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?
@xroneyaa on GitHub · 2026-11-24 06:10 UTC · original
xroneyaa:fix/xdxr-stream-record-bounds→main· +16 −4 · 2 files · 1 commits · merged 2026-11-24 16:11 UTCClaimed in the coordination issue as: XDXR-STREAM-RECORD-BOUNDS
What and why
leonida::xdxr::find_stream_record()inruntime/src/xdxr_descs.hcomputedend = reinterpret_cast<const StreamRecord*>(static_cast<const uint8_t*>(desc.stream) + desc.size_in_bytes)and loopedfor (; record < end; ++record). Wheneversize_in_byteswas not a multiple ofsizeof(StreamRecord)(16 bytes), the last iteration read a full 16-byte record past the caller's buffer end, and a very largesize_in_bytescould wrap pointer addition.This checks
desc.size_in_bytes < sizeof(StreamRecord) || desc.stream == nullptrand iterates strictly overcount = desc.size_in_bytes / sizeof(StreamRecord)complete records. Added boundary unit tests inruntime/test/xdxr_descs_test.cppfor sizes1,4,15,17, and31bytes.Tested
xdxr_descs_testwith MSVC 19.50 / Ninja (0 warnings)ctest --test-dir runtime/build -R "^xdxr_descs$" --output-on-failure-> 1/1 Passed (0.01 s)python -I scripts/check_no_game_data.py runtime/src/xdxr_descs.h runtime/test/xdxr_descs_test.cpp-> exit 0GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed (n/a — no translator rule added).@Oliwettoo on GitHub · 2026-11-24 10:39 UTC · original
Looks good. Counting whole records stops
find_stream_recordfrom reading a trailing partialStreamRecord(and from reading 16 bytes out of a stream shorter than one). Builtxdxr_descs_testwith g++ on Linux: it passes with the PR, and the PR's test fails againstmain's header, so it guards the change. Ship. AI-assisted review.@kawaii-shakal on GitHub · 2026-11-24 11:39 UTC · original
Independent run on Windows: passes.
Head
36e9f9fcebuilt as it is (RelWithDebInfo, MSVC 19.50.35721.0):ctest -R xdxr_descs1/1 passed, with and withoutLEONIDA_VK_VALIDATION=1. The diff reads right to me: aStreamRecordis accepted only when all 16 bytes fit, so a truncated tail no longer reads past the buffer.GPU: NVIDIA GeForce RTX 5070 Ti, driver 617.42, Vulkan 1.4.351, Windows 11 Pro 26300 (the test itself is CPU-only).
AI-assisted.