1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-09 03:56:01 +01:00

nix {cat,ls}: Add back missing checks for file descriptors

I didn't catch this during the review of https://github.com/NixOS/nix/pull/14273.
This fixes that mistake.
This commit is contained in:
Sergei Zimmerman 2025-10-17 02:26:24 +03:00
parent 64c55961eb
commit e457ea7688
No known key found for this signature in database
2 changed files with 4 additions and 0 deletions

View file

@ -76,6 +76,8 @@ struct CmdCatNar : StoreCommand, MixCat
void run(ref<Store> store) override void run(ref<Store> store) override
{ {
AutoCloseFD fd = open(narPath.c_str(), O_RDONLY); AutoCloseFD fd = open(narPath.c_str(), O_RDONLY);
if (!fd)
throw SysError("opening NAR file '%s'", narPath);
auto source = FdSource{fd.get()}; auto source = FdSource{fd.get()};
auto narAccessor = makeNarAccessor(source); auto narAccessor = makeNarAccessor(source);
auto listing = listNar(narAccessor, CanonPath::root, true); auto listing = listNar(narAccessor, CanonPath::root, true);

View file

@ -146,6 +146,8 @@ struct CmdLsNar : Command, MixLs
void run() override void run() override
{ {
AutoCloseFD fd = open(narPath.c_str(), O_RDONLY); AutoCloseFD fd = open(narPath.c_str(), O_RDONLY);
if (!fd)
throw SysError("opening NAR file '%s'", narPath);
auto source = FdSource{fd.get()}; auto source = FdSource{fd.get()};
auto narAccessor = makeNarAccessor(source); auto narAccessor = makeNarAccessor(source);
auto listing = listNar(narAccessor, CanonPath::root, true); auto listing = listNar(narAccessor, CanonPath::root, true);