#include #include #include #include namespace DB { CompressionCodecPtr getCompressionCodecDelta(UInt8 delta_bytes_size); } struct AuxiliaryRandomData { UInt8 delta_size_bytes; size_t decompressed_size; }; extern "C" int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size) try { if (size < sizeof(AuxiliaryRandomData)) return 0; auto * p = reinterpret_cast(data); auto codec = DB::getCompressionCodecDelta(p->delta_size_bytes); size_t output_buffer_size = p->decompressed_size % 65536; size -= sizeof(AuxiliaryRandomData); data += sizeof(AuxiliaryRandomData) / sizeof(uint8_t); std::string input = std::string(reinterpret_cast(data), size); fmt::print(stderr, "Using input {} of size {}, output size is {}. \n", input, size, output_buffer_size); if (output_buffer_size < size) return 0; DB::Memory<> memory; memory.resize(output_buffer_size + codec->getAdditionalSizeAtTheEndOfBuffer()); codec->doDecompressData(reinterpret_cast(data), size, memory.data(), output_buffer_size); return 0; } catch (...) { return 1; }