XDXR-STREAM-RECORD-BOUNDS: require complete 16-byte StreamRecords in find_stream_record #484
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/484"
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?
Imported from ubiquitarianism/leonida. Originally posted by xroneyaa on 2026-11-24T06:10:21Z.
Claimed 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).Imported from ubiquitarianism/leonida. Originally posted by Oliwettoo on 2026-11-24T10:39:05Z.
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.Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-24T11:39:12Z.
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.