pipeline_cache_journal: guard null bytes/kind and avoid entry_path truncation #2307

Merged
narekshaghoyandev merged 1 commit from upstream-pr/2307 into main 2026-11-28 18:11:02 +00:00
narekshaghoyandev commented 2026-11-26 13:35:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by narekshaghoyandev on 2026-11-26T13:35:00Z.


Fixes null-pointer dereferences and fixed-buffer truncation in runtime/src/pipeline_cache_journal.h:

  • Guard Hasher::bytes(const void* data, std::size_t size) against data == nullptr (or size == 0) before dereferencing.
  • Build the filename in entry_path() dynamically (std::string + suffix) instead of snprintf into a fixed 64-byte buffer, and default null/empty kind to "entry" so long kind names never truncate the hex key/.bin suffix and null kind never triggers UB.
  • Added regression tests in runtime/test/pipeline_cache_journal_test.cpp covering null Hasher::bytes, null kind, and 60-char kind in entry_path().

Verification

  • g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic passed
  • g++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic passed
  • Negative control: new regression test crashed (SIGSEGV, exit 139) against unmodified ubiq/main
  • python3 -I scripts/check_no_game_data.py runtime/src/pipeline_cache_journal.h runtime/test/pipeline_cache_journal_test.cpp clean

Claimed in the coordination issue as: RT-PIPELINE-JOURNAL-NULL-AND-KIND (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193017383)
AI-assisted: yes (Gemini)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5511003503 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2307). Originally posted by [narekshaghoyandev](https://github.com/narekshaghoyandev) on 2026-11-26T13:35:00Z. --- Fixes null-pointer dereferences and fixed-buffer truncation in `runtime/src/pipeline_cache_journal.h`: - Guard `Hasher::bytes(const void* data, std::size_t size)` against `data == nullptr` (or `size == 0`) before dereferencing. - Build the filename in `entry_path()` dynamically (`std::string` + `suffix`) instead of `snprintf` into a fixed 64-byte buffer, and default null/empty `kind` to `"entry"` so long `kind` names never truncate the hex key/`.bin` suffix and null `kind` never triggers UB. - Added regression tests in `runtime/test/pipeline_cache_journal_test.cpp` covering null `Hasher::bytes`, null `kind`, and 60-char `kind` in `entry_path()`. ### Verification - `g++ -std=c++20 -D_GLIBCXX_DEBUG -Wall -Wextra -Werror -pedantic` passed - `g++ -std=c++20 -fsanitize=address,undefined -Wall -Wextra -Werror -pedantic` passed - Negative control: new regression test crashed (SIGSEGV, exit 139) against unmodified `ubiq/main` - `python3 -I scripts/check_no_game_data.py runtime/src/pipeline_cache_journal.h runtime/test/pipeline_cache_journal_test.cpp` clean Claimed in the coordination issue as: RT-PIPELINE-JOURNAL-NULL-AND-KIND (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7193017383) AI-assisted: yes (Gemini)
lixonik commented 2026-11-26 17:57:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-26T17:57:36Z.

Review: COMMENTED


Windows 11/MSVC: pipeline_cache_journal CTest passed, including the synthetic null-input and long filename cases. No findings from these checks.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6078689424 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2307#pullrequestreview-6078689424). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-26T17:57:36Z. **Review:** COMMENTED --- Windows 11/MSVC: `pipeline_cache_journal` CTest passed, including the synthetic null-input and long filename cases. No findings from these checks. AI-assisted.
zmasi commented 2026-11-28 12:38:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T12:38:49Z.


Verified on Windows 11 (10.0.26200.9974) with MSVC 19.44.35228 (x64, /std:c++20 /EHsc /W4 /permissive- /utf-8 /O2) against main d48a957bb + 0791348ed4 (claim #2570#issuecomment-7239309422):

  • Line-by-line diff audit: Clean (runtime/src/pipeline_cache_journal.h, runtime/test/pipeline_cache_journal_test.cpp); guards Hasher::bytes against nullptr / zero length and constructs entry_path filenames with "entry" fallback for null/empty kind plus dynamic std::string concatenation so long kind prefixes are never truncated at 64 bytes. check_no_game_data.py clean.
  • Red (d48a957bb + PR test): pipeline_cache_journal_test.exe crashes with 0xc0000005 (STATUS_ACCESS_VIOLATION) on null_h.bytes(nullptr, 16).
  • Green (d48a957bb + 0791348ed4 merge): Auto-merges cleanly (rc=0), introduces 0 new compiler warnings, and passes (pipeline_cache_journal_test: ok, rc=0).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7239370737 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2307#issuecomment-7239370737). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T12:38:49Z. --- Verified on Windows 11 (`10.0.26200.9974`) with MSVC `19.44.35228` (`x64`, `/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2`) against `main` `d48a957bb` + `0791348ed4` (claim `#2570#issuecomment-7239309422`): - **Line-by-line diff audit**: Clean (`runtime/src/pipeline_cache_journal.h`, `runtime/test/pipeline_cache_journal_test.cpp`); guards `Hasher::bytes` against `nullptr` / zero length and constructs `entry_path` filenames with `"entry"` fallback for null/empty `kind` plus dynamic `std::string` concatenation so long `kind` prefixes are never truncated at 64 bytes. `check_no_game_data.py` clean. - **Red (`d48a957bb` + PR test)**: `pipeline_cache_journal_test.exe` crashes with **`0xc0000005` (`STATUS_ACCESS_VIOLATION`)** on `null_h.bytes(nullptr, 16)`. - **Green (`d48a957bb` + `0791348ed4` merge)**: Auto-merges cleanly (`rc=0`), introduces `0` new compiler warnings, and passes (`pipeline_cache_journal_test: ok`, `rc=0`). AI-assisted.
MoonEyes commented 2026-11-28 18:11:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T18:11:00Z.


Red/green: On main pipeline_cache_journal_test crashes with a segmentation fault (null bytes passed to the journal), and with the PR ctest -R "^pipeline_cache_journal$" passes.
Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243594007 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2307#issuecomment-7243594007). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T18:11:00Z. --- Red/green: On main pipeline_cache_journal_test crashes with a segmentation fault (null bytes passed to the journal), and with the PR ctest -R "^pipeline_cache_journal$" passes. Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.
OreoFR commented 2026-11-28 22:01:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T22:01:40Z.


Verified by OreoFR

  • Base: main c1ecf04ed + PR head 0791348ed; green run in a merge package of 16 PRs, no new ctest failure vs main
  • Test: ctest -R "^pipeline_cache_journal$"
  • Red on main: crash (SegFault)
  • Green with the PR: OK
  • Verdict: READY
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246443868 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2307#issuecomment-7246443868). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T22:01:40Z. --- **Verified by OreoFR** - Base: main `c1ecf04ed` + PR head `0791348ed`; green run in a merge package of 16 PRs, no new ctest failure vs main - Test: `ctest -R "^pipeline_cache_journal$"` - Red on main: crash (SegFault) - Green with the PR: OK - Verdict: READY - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!2307
No description provided.