Fix CouponList deserialization count validation bug#503
Conversation
tisonkun
left a comment
There was a problem hiding this comment.
LGTM. Thanks for your contribution!
There was a problem hiding this comment.
Pull request overview
This PR tightens CouponList (LIST-mode) deserialization by validating the declared coupon count against the fixed LIST backing-array capacity, preventing malformed serialized data from causing unsafe reads/writes during deserialization. It also adds regression tests covering both byte-array and stream deserialization entry points.
Changes:
- Add LIST coupon-count capacity validation in
CouponList::newList()for both byte-array and stream paths. - Add new unit tests that mutate serialized bytes/streams to declare an oversized LIST coupon count and assert
std::invalid_argument.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| hll/test/CouponListTest.cpp | Adds regression tests for malformed LIST coupon-count handling in bytes and stream deserialization. |
| hll/include/CouponList-internal.hpp | Adds LIST coupon-count validation during deserialization (bytes + stream). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8213aac to
c10bc43
Compare
0a8efef to
805eaf3
Compare
|
Hi @tisonkun. Following Copilot's suggestion, I reject cases where |
This fixes a CouponList deserialization bug where LIST-mode serialized data could declare a coupon count larger than the fixed LIST capacity.
The change validates the declared LIST count before reading coupon data, and applies the check to both byte-array and stream deserialization paths.
Tests
cmake --build build/Release --target hll_test./build/Release/hll/test/hll_testctest --test-dir build/Release -R hll_test --output-on-failurectest --test-dir build/ASan -R hll_test --output-on-failurecc @tisonkun