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

   `FrequentItemsSketch::deserialize` used the `lg_max_map_size` / 
`lg_cur_map_size` header bytes to size and left-shift the backing hash map 
without validating their range. A corrupt header with a large `lg_max_map_size` 
drives `1usize << lg_max` in `with_lg_map_sizes` past the width of `usize`, 
panicking with "attempt to shift left with overflow" in debug builds and 
requesting an oversized allocation in release builds — even on the empty-sketch 
path, before any payload is read.
   
   This validates the map-size fields up front, mirroring the C++ reference 
`check_size` (`lg_cur >= LG_MIN_MAP_SIZE`, `lg_cur <= lg_max`) and adding an 
upper bound on `lg_max` (`LG_MAX_MAP_SIZE = 30`, matching CountMin's 
`MAX_TABLE_ENTRIES`) that Rust needs to keep the shift and allocation 
well-defined. Malformed input now returns `Error::deserial` instead of crashing.
   
   Adds regression tests for out-of-range `lg_max_map_size` (empty and 
non-empty headers), undersized `lg_cur_map_size`, and a valid header. CHANGELOG 
updated.
   


-- 
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