Commit Graph

4 Commits

Author SHA1 Message Date
Emil Velikov
0f7fd27524 Use context-less zstd decompression API
Currently we pre-allocate around 128K of zstd state ahead of time,
keeping if for the whole daemon lifetime... Even if we don't need to
decompress any files. As mentioned by Dmitry:

    Granted that tqftpserv handles only few files during the whole
    lifetime and most of devices don't have swap, I think it's fine to
    use non-context versions of the functions. Let's free the memory for
    other software.

Swap ZSTD_decompressDCtx() for ZSTD_decompress() which will allocate and
free the state when needed.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2024-09-21 16:09:21 +01:00
Emil Velikov
95d0c67322 Explicitly open zstd file as read-only
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2024-09-19 12:53:27 +01:00
Emil Velikov
085a87c279 Clear memory leaks during zstd decompression
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2024-09-19 12:48:16 +01:00
Stefan Hansson
0197df8e61 Add support for zstd-compressed readonly files
We need this to load compressed files from linux-firmware.

Closes https://github.com/linux-msm/tqftpserv/issues/19

Signed-off-by: Stefan Hansson <newbyte@postmarketos.org>
Tested-by: Nikita Travkin <nikita@trvn.ru>
2024-07-23 14:20:00 +02:00