Fix an issue where the ByteSource path (used for parsing std::string)
would incorrectly accept some invalid varints that the other path would not, causing potential CHECK-failures if the unit test were run with --write_uncompressed and a corrupted input file. Found by the afl fuzzer.
This commit is contained in:
@@ -1007,6 +1007,20 @@ TEST(SnappyCorruption, UnterminatedVarint) {
|
||||
&uncompressed));
|
||||
}
|
||||
|
||||
TEST(SnappyCorruption, OverflowingVarint) {
|
||||
string compressed, uncompressed;
|
||||
size_t ulength;
|
||||
compressed.push_back('\xfb');
|
||||
compressed.push_back('\xff');
|
||||
compressed.push_back('\xff');
|
||||
compressed.push_back('\xff');
|
||||
compressed.push_back('\x7f');
|
||||
CHECK(!CheckUncompressedLength(compressed, &ulength));
|
||||
CHECK(!snappy::IsValidCompressedBuffer(compressed.data(), compressed.size()));
|
||||
CHECK(!snappy::Uncompress(compressed.data(), compressed.size(),
|
||||
&uncompressed));
|
||||
}
|
||||
|
||||
TEST(Snappy, ReadPastEndOfBuffer) {
|
||||
// Check that we do not read past end of input
|
||||
|
||||
|
||||
Reference in New Issue
Block a user