LZ4_decompress_safe(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’œ 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 the dest buffer 🫢

⭐ 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


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