SavicStefan opened a new pull request, #511:
URL: https://github.com/apache/datasketches-cpp/pull/511

   The entry-reading loop reads each entry as an 8-byte key followed by a 
Summary-width summary. The summary read is passed the remaining capacity and 
bounds-checks itself, but the key read is an unchecked fixed-size copy_from_mem 
that relies solely on the pre-loop keys-only reservation, which assumes every 
entry's summary occupies the width Summary serializes to.
   
   When that assumption does not hold (a truncated buffer, or a buffer whose 
serialized summary width differs from the Summary it is deserialized as) the 
read cursor advances past the data. num_entries is read from the preamble and 
is unaffected, so the loop runs the full count and a later key read walks off 
the end of the buffer: silent on a normal build, a heap-buffer-overflow under 
AddressSanitizer.
   
   Add an ensure_minimum_memory check before the key read, mirroring the 
remaining-capacity check the summary read already performs and the up-front 
size validation the compact theta parser does. A malformed buffer now throws 
std::out_of_range instead of reading out of bounds.
   
   Adds a tuple_sketch_test case that deserializes a float-summary sketch as a 
double-summary sketch and asserts std::out_of_range.


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