cestercian opened a new pull request, #221:
URL: https://github.com/apache/datasketches-rust/pull/221

   Fixes #218
   
   ## Summary
   
   REQ deserialization accepted compactor states that a valid sketch cannot 
produce. Those images later panicked in `ReqSketch::merge` or returned a 
`rank()` outside `[0.0, 1.0]`. Deserialize now rejects those states with 
`ErrorKind::InvalidData`.
   
   ## Changes Made
   
   - `Compactor::deserialize` rejects `num_sections` values that the REQ 
doubling schedule cannot produce, including `num_sections = 0`. Malformed wire 
fields now return `ErrorKind::InvalidData` instead of `InvalidArgument`.
   - `ReqSketch::deserialize` requires each compactor's `lg_weight` to equal 
its enclosing level index.
   - `ReqSketch::deserialize` uses checked arithmetic for the retained weighted 
count and requires it to equal serialized `n`.
   - Regression tests in `datasketches/tests/serde_tests/req.rs` cover the two 
malformed single-level images from the issue.
   
   ## Related Issue
   
   https://github.com/apache/datasketches-rust/issues/218
   
   ## Testing Steps
   
   1. `cargo x test` (from the repo root; run `cargo x prepare-testdata` first 
if serialization fixtures are missing)
   2. `cargo x lint`
   3. Confirm the new serde tests fail the two crafted images with 
`ErrorKind::InvalidData`:
      - single-level image with `num_sections = 0`
      - single-level image with level-0 `lg_weight = 63` and one item
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to