Skip to content

test: cover adaptive Huffman decompression#203

Draft
cursor[bot] wants to merge 1 commit into
next-gen-5from
cursor/regression-test-coverage-c4d9
Draft

test: cover adaptive Huffman decompression#203
cursor[bot] wants to merge 1 commit into
next-gen-5from
cursor/regression-test-coverage-c4d9

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented May 9, 2026

Risky behavior now covered

  • Direct adaptive Huffman compression/decompression round-trip for binary packet payloads with nonzero network offsets.
  • Malformed/truncated compressed streams now stop at the available cursor, zero-fill unread decoded bytes deterministically, and cap declared output length to the message buffer.
  • Decoded NUL symbols are distinguished from receive failures in the adaptive Huffman decoder.

Test files added/updated

  • Added tests/unit/test_huffman_adaptive.c.
  • Registered unit_huffman_adaptive in CMakeLists.txt with unit;validation;network labels.
  • Hardened src/qcommon/huffman.c bounds handling for truncated adaptive streams so the regression tests assert deterministic safe behavior.

Why these tests reduce regression risk

Adaptive Huffman is on the shared client/server packet path (net_chan.c, sv_main.c) and the existing unit_msg target only exercises the separate static Huffman helpers. These tests cover a security-sensitive decompression boundary without requiring networking, game data, a display server, or GPU hardware.

Validation

  • cmake -S . -B build-coverage-tests -DBUILD_TESTING=ON -DBUILD_UNIT_TESTS=ON
  • cmake --build build-coverage-tests --target unit_huffman_adaptive
  • ctest --test-dir build-coverage-tests -R unit_huffman_adaptive --output-on-failure
Open in Web View Automation 

Co-authored-by: Tim Fox <timfox@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant