LZ4_decompress_safe(9)
π LZ4_decompress_safe(9) β the kernel API manual, bestie edition π
Okay so this page is from the Kernel API Manual, and today's main character is LZ4_decompress_safe. She unpacks compressed data for you and she is literally built different when it comes to buffer overflows. Periodt. π₯
β¨ NAME β¨
LZ4_decompress_safe β decompression that's protected against buffer overflow π‘οΈβ¨
πΈ SYNOPSIS πΈ
int LZ4_decompress_safe (const char *source , char *dest , int
compressedSize , int maxDecompressedSize );
π¦ ARGUMENTS π¦
sourceβ the source address of the compressed data, iykyk πdestβ the output buffer address of the uncompressed data, and ngl it must be already allocated before you call this. She does not malloc for you, she's not your mom πcompressedSizeβ the precise full size of the compressed block. Like, precise. The whole thing. πmaxDecompressedSizeβ the size of thedestbuffer π«Ά
β DESCRIPTION β
So what she does is decompress data from source into dest. That's the whole vibe. π
But here's the serve: if the source stream is detected as malformed, the function will stop decoding and return a negative result. She's not gonna keep going and pretend it's fine β she checks the vibe and bails π
This function is protected against buffer overflow exploits, including malicious data packets. It never writes outside the output buffer, nor reads outside the input buffer. Feral input data? She's unbothered. Iconic behaviour, no cap. π
π₯ RETURN π₯
The number of bytes decompressed into the destination buffer β which is necessarily <= maxDecompressedSize β or a negative result in case of error π
π§ SEE ALSO π§
Kernel file ./include/linux/lz4.h
LZ4_compressBound(9)LZ4_compress_default(9)LZ4_compress_fast(9)LZ4_compress_destSize(9)LZ4_decompress_fast(9)LZ4_decompress_safe_partial(9)LZ4_compress_HC(9)LZ4_resetStreamHC(9)LZ4_loadDictHC(9)LZ4_compress_HC_continue(9)LZ4_saveDictHC(9)LZ4_resetStream(9)LZ4_loadDict(9)LZ4_saveDict(9)LZ4_compress_fast_continue(9)LZ4_setStreamDecode(9)LZ4_decompress_safe_continue(9)LZ4_decompress_fast_continue(9)LZ4_decompress_safe_usingDict(9)LZ4_decompress_fast_usingDict(9)
That's the whole page bestie β mwah π This one lives in ./include/linux and the page is stamped October 2026, so go forth and decompress safely, my love ππΈπ«Ά
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms