1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 21:41:48 +02:00

fix(libutil): apply only the specified filter to decompress archive

This patch makes `makeDecompressionSink` strip only a single layer
of compression specified via method. This fixes erroneous decompression
of doubly-compressed NARs fetched with curl.
This commit is contained in:
Sergei Zimmerman 2024-03-30 01:29:29 +03:00
parent 6d9bafb3b8
commit 500683a949
No known key found for this signature in database
GPG key ID: A9B0B557CA632325
3 changed files with 63 additions and 20 deletions

View file

@ -15,18 +15,28 @@ struct TarArchive
void check(int err, const std::string & reason = "failed to extract archive (%s)");
TarArchive(Source & source, bool raw = false);
explicit TarArchive(const Path & path);
TarArchive(const Path & path);
/// @brief Create a generic archive from source.
/// @param source - Input byte stream.
/// @param raw - Whether to enable raw file support. For more info look in docs:
/// https://manpages.debian.org/stretch/libarchive-dev/archive_read_format.3.en.html
/// @param compression_method - Primary compression method to use. std::nullopt means 'all'.
TarArchive(Source & source, bool raw = false, std::optional<std::string> compression_method = std::nullopt);
/// disable copy constructor
/// Disable copy constructor. Explicitly default move assignment/constructor.
TarArchive(const TarArchive &) = delete;
TarArchive & operator=(const TarArchive &) = delete;
TarArchive(TarArchive &&) = default;
TarArchive & operator=(TarArchive &&) = default;
void close();
~TarArchive();
};
int getArchiveFilterCodeByName(const std::string & method);
void unpackTarfile(Source & source, const Path & destDir);
void unpackTarfile(const Path & tarFile, const Path & destDir);