Repository navigation
Conversation
…d underflow Add defensive pointer and bounds validation across public C API functions, C++ compression/decompression routines, and Source/Sink implementations. Specifically: * Validate input, output, and length pointers in snappy-c public entry points (snappy_compress, snappy_compress_with_level, snappy_uncompress, snappy_uncompressed_length, snappy_validate_compressed_buffer), returning SNAPPY_INVALID_INPUT on null pointer arguments. * Prevent unsigned integer underflow in ByteArraySource::Skip by clamping the skip count to the available byte count. * Initialize left_ to 0 in ByteArraySource constructor when the data pointer is null. * Validate function pointer deleter before invocation and allocated_size pointer before assignment in Sink and UncheckedByteArraySink. * Guard against null Source, Sink, CompressionContext, buffer, and length pointers in C++ entry points (Compress, RawCompress, RawUncompress, Uncompress, UncompressAsMuchAsPossible, GetUncompressedLength). * Add NullPointerAndBoundsGuards unit test in snappy_unittest.cc verifying safe error handling across all guarded entry points. Signed-off-by: Filippo Tedeschi <filippotedeschi98@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This patch hardens Snappy public C API entry points, C++ compression and decompression routines, and Source and Sink implementations against null pointer dereferences and unsigned integer underflow.
Detailed Changes
Public C API (snappy-c.cc):
Source and Sink Safety (snappy-sinksource.h, snappy-sinksource.cc):
to left_.
C++ API Pointer Guards (snappy.cc):
Unit Test Coverage (snappy_unittest.cc):