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:
@@ -545,7 +545,9 @@ class SnappyDecompressor {
|
||||
if (n == 0) return false;
|
||||
const unsigned char c = *(reinterpret_cast<const unsigned char*>(ip));
|
||||
reader_->Skip(1);
|
||||
*result |= static_cast<uint32>(c & 0x7f) << shift;
|
||||
uint32 val = c & 0x7f;
|
||||
if (((val << shift) >> shift) != val) return false;
|
||||
*result |= val << shift;
|
||||
if (c < 128) {
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user