-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
Describe the bug
In the function parse
in src/libutil/archive.cc, the if
at line 191 does not have an else
branch, leading to the string being ignored.
Steps To Reproduce
- Run the following script using
zig run
and pump its contents into a file.
const std = @import("std");
pub fn main() !void {
var sw = std.fs.File.stdout().writer(&.{});
const writer = &sw.interface;
try writer.writeAll(archive);
}
inline fn str(comptime s: []const u8) []const u8 {
return std.mem.asBytes(&std.mem.nativeToLittle(u64, s.len)) ++
s ++ &@as([padding(s.len)]u8, @splat(0));
}
inline fn padding(comptime l: u64) u3 {
return @truncate(-%l);
}
const archive = blk: {
var cur: []const u8 = "";
for (tokens) |t| cur = cur ++ str(t);
break :blk cur;
};
const tokens: []const []const u8 = &.{
"nix-archive-1",
"(",
"type",
"regular",
//"executable", "",
"AAAAAAAA", // something other than "contents" or "executable"
")",
};
- Run
nix nar cat ARCHIVE /
on the resulting archive
[clevor@clevor-laptop-nixos:/tmp/clevor/bruh]$ zig run create.zig > archive.nar
[clevor@clevor-laptop-nixos:/tmp/clevor/bruh]$ nix nar cat archive.nar /
[clevor@clevor-laptop-nixos:/tmp/clevor/bruh]$ echo $?
0
Expected behavior
[clevor@clevor-laptop-nixos:/tmp/clevor/bruh]$ nix nar cat archive.nar /
error: bad archive: expected tag 'contents', got 'AAAAAAAA'
Metadata
nix-env (Nix) 2.28.5
Additional context
Checklist
- checked latest Nix manual (source)
- checked open bug issues and pull requests for possible duplicates
Add 👍 to issues you find important.