rocksdb: don't call LZ4_loadDictHC with null dictionary

Summary: UBSAN revealed a pointer underflow when `LZ4HC_init_internal` is called with a null `start`.

Reviewed By: ajkr

Differential Revision: D30181874

fbshipit-source-id: ca9bbac1a85c58782871d7f153af733b000cc66c
This commit is contained in:
Lucian Grijincu 2021-08-09 16:04:26 -07:00 committed by Andrew Kryczka
parent 2dea3dd258
commit c3034fce32

View File

@ -1224,8 +1224,10 @@ inline bool LZ4HC_Compress(const CompressionInfo& info,
const char* compression_dict_data = const char* compression_dict_data =
compression_dict.size() > 0 ? compression_dict.data() : nullptr; compression_dict.size() > 0 ? compression_dict.data() : nullptr;
size_t compression_dict_size = compression_dict.size(); size_t compression_dict_size = compression_dict.size();
LZ4_loadDictHC(stream, compression_dict_data, if (compression_dict_data != nullptr) {
static_cast<int>(compression_dict_size)); LZ4_loadDictHC(stream, compression_dict_data,
static_cast<int>(compression_dict_size));
}
#if LZ4_VERSION_NUMBER >= 10700 // r129+ #if LZ4_VERSION_NUMBER >= 10700 // r129+
outlen = outlen =