Reputation: 180
I'm writing some code to decompress an LZ4 encoded buffer. The operation fails when calling LZ4_decompress_safe
. The error given is 'ERROR_contentChecksumFlag_invalid'. There is nothing wrong with the input data, because I wrote the same buffer out to a file and used unlz4 to decode it fine. The lz4-dev lib version I'm using is 1.7.1 (Xenial Ubuntu Pkg).
The lz4 lib that unlz4 uses is 1.7.1. I'm at a loss of what the issue is.
The code I'm using:
std::ofstream dbgfile("~/lz4_dbg", std::ios::out | std::ios::binary);
dbgfile.write(entry_buffer, entry_size);
dbgfile.close();
char* lz4_buffer = (char*)calloc(1, entry_size*4);
uint64_t bytes_decompressed = LZ4_decompress_safe(entry_buffer, lz4_buffer, entry_size, entry_size * 4);
std::string err = LZ4F_getErrorName(bytes_decompressed);
Upvotes: 1
Views: 2119
Reputation: 180
So the problem was that I just wasn't familiar with the lz4 library and didn't realize there was two different ways to decompress lz4 data (via LZ4 or LZ4Framing).
Using regular LZ4 failed, but switching to LZ4Framing worked.
Thanks Shawn.
Upvotes: 2