Skip to content

Commit

Permalink
Restrict supported tarball formats to actual Tarballs
Browse files Browse the repository at this point in the history
The documentation is clear about the supported formats (with at least
`builtins.fetchTarball`). The way the code was written previously it
supported all the formats that libarchive supported. That is a
surprisingly large amount of formats that are likely not on the radar
of the Nix developers and users. Before people end up relying on
this (or if they do) it is better to break it now before it becomes a
widespread "feature".

Zip file support has been retained as (at least to my knowledge)
historically that has been used to fetch nixpkgs in some shell
expressions *many* years back.

Fixes #10917
  • Loading branch information
andir committed Jun 15, 2024
1 parent 573e385 commit 5a9e1c0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/libutil/tarfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ TarArchive::TarArchive(Source & source, bool raw, std::optional<std::string> com
}

if (!raw) {
archive_read_support_format_all(archive);
archive_read_support_format_tar(archive);
archive_read_support_format_zip(archive);
} else {
archive_read_support_format_raw(archive);
archive_read_support_format_empty(archive);
Expand All @@ -96,7 +97,8 @@ TarArchive::TarArchive(const Path & path)
, buffer(defaultBufferSize)
{
archive_read_support_filter_all(archive);
archive_read_support_format_all(archive);
archive_read_support_format_tar(archive);
archive_read_support_format_zip(archive);
archive_read_set_option(archive, NULL, "mac-ext", NULL);
check(archive_read_open_filename(archive, path.c_str(), 16384), "failed to open archive: %s");
}
Expand Down

0 comments on commit 5a9e1c0

Please sign in to comment.