mirror of
https://github.com/DeusData/codebase-memory-mcp.git
synced 2026-12-05 04:47:43 +08:00
The import path allocated the destination from the plaintext original_size field in artifact.json and passed that value to the decoder truncated through int. A large real database already wraps that cast (a full-kernel index is ~14 GB), and a doctored field could additionally desync the decoder capacity from the actual buffer. Read the decompressed size from the zstd frame's own content-size header, require the metadata field to match it, cap the total, and run the decoder with a size_t capacity equal to the allocation. cbm_zstd_decompress now takes size_t lengths and returns int64_t. Adds a regression test that a mismatched original_size is rejected. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>