[PR #484] [MERGED] XDXR-STREAM-RECORD-BOUNDS: require complete 16-byte StreamRecords in find_stream_record #534

Closed
opened 2026-11-26 20:18:12 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/484
Author: @xroneyaa
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @ubiquitarianism

Base: main ← Head: fix/xdxr-stream-record-bounds


📝 Commits (1)

  • 36e9f9f xdxr_descs: require complete 16-byte StreamRecords in find_stream_record

📊 Changes

2 files changed (+16 additions, -4 deletions)

View changed files

📝 runtime/src/xdxr_descs.h (+3 -4)
📝 runtime/test/xdxr_descs_test.cpp (+13 -0)

📄 Description

Claimed in the coordination issue as: XDXR-STREAM-RECORD-BOUNDS

What and why

leonida::xdxr::find_stream_record() in runtime/src/xdxr_descs.h computed end = reinterpret_cast<const StreamRecord*>(static_cast<const uint8_t*>(desc.stream) + desc.size_in_bytes) and looped for (; record < end; ++record). Whenever size_in_bytes was not a multiple of sizeof(StreamRecord) (16 bytes), the last iteration read a full 16-byte record past the caller's buffer end, and a very large size_in_bytes could wrap pointer addition.

This checks desc.size_in_bytes < sizeof(StreamRecord) || desc.stream == nullptr and iterates strictly over count = desc.size_in_bytes / sizeof(StreamRecord) complete records. Added boundary unit tests in runtime/test/xdxr_descs_test.cpp for sizes 1, 4, 15, 17, and 31 bytes.

Tested

  • Rebuilt xdxr_descs_test with 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 0

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed (n/a — no translator rule added).

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/484 **Author:** [@xroneyaa](https://github.com/xroneyaa) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@ubiquitarianism](https://github.com/ubiquitarianism) **Base:** `main` ← **Head:** `fix/xdxr-stream-record-bounds` --- ### 📝 Commits (1) - [`36e9f9f`](https://github.com/ubiquitarianism/leonida/commit/36e9f9fce9bc33a4074ee6a37c3379a9fb5864cb) xdxr_descs: require complete 16-byte StreamRecords in find_stream_record ### 📊 Changes **2 files changed** (+16 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/xdxr_descs.h` (+3 -4) 📝 `runtime/test/xdxr_descs_test.cpp` (+13 -0) </details> ### 📄 Description Claimed in the coordination issue as: XDXR-STREAM-RECORD-BOUNDS ### What and why `leonida::xdxr::find_stream_record()` in `runtime/src/xdxr_descs.h` computed `end = reinterpret_cast<const StreamRecord*>(static_cast<const uint8_t*>(desc.stream) + desc.size_in_bytes)` and looped `for (; record < end; ++record)`. Whenever `size_in_bytes` was not a multiple of `sizeof(StreamRecord)` (16 bytes), the last iteration read a full 16-byte record past the caller's buffer end, and a very large `size_in_bytes` could wrap pointer addition. This checks `desc.size_in_bytes < sizeof(StreamRecord) || desc.stream == nullptr` and iterates strictly over `count = desc.size_in_bytes / sizeof(StreamRecord)` complete records. Added boundary unit tests in `runtime/test/xdxr_descs_test.cpp` for sizes `1`, `4`, `15`, `17`, and `31` bytes. ### Tested - Rebuilt `xdxr_descs_test` with 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 0 GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed (n/a — no translator rule added). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:12 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#534
No description provided.