From 7579d5d84f92e5d69d7caabff5fb5c80892c8364 Mon Sep 17 00:00:00 2001 From: Sami Boukortt Date: Tue, 5 Jul 2022 07:07:32 +0200 Subject: [PATCH] lzo: unpoison the working buffer (#7941) The compression function appears to account for the possibility that the buffer contains random values, but msan does not realize that. Initializing the buffer would be another option, but mere unpoisoning maintains the ability to detect flaws in the way that the library handles such uninitialized buffers. (Although, arguably, perhaps this would be better served by separate fuzzing, which would also make such findings more reproducible.) This fixes b/154387018. --- projects/lzo/all_lzo_compress.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/lzo/all_lzo_compress.cc b/projects/lzo/all_lzo_compress.cc index 13c3d113d..510f6aeb0 100644 --- a/projects/lzo/all_lzo_compress.cc +++ b/projects/lzo/all_lzo_compress.cc @@ -202,6 +202,10 @@ void FuzzLzoAlgorithm(const LzoAlgorithm& algorithm, std::unique_ptr compressed_buffer( new uint8_t[algorithm.GetMaxCompressedSize(input_buffer.size())]); +#if MEMORY_SANITIZER + __msan_unpoison(working_buffer.get(), algorithm.working_memory_size); +#endif + lzo_uint compressed_size; if (algorithm.compress_fn(input_buffer.data(), input_buffer.size(), compressed_buffer.get(), &compressed_size,