Skip to content

Commit e457ea7

Browse files
committed
nix {cat,ls}: Add back missing checks for file descriptors
I didn't catch this during the review of #14273. This fixes that mistake.
1 parent 64c5596 commit e457ea7

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/nix/cat.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ struct CmdCatNar : StoreCommand, MixCat
7676
void run(ref<Store> store) override
7777
{
7878
AutoCloseFD fd = open(narPath.c_str(), O_RDONLY);
79+
if (!fd)
80+
throw SysError("opening NAR file '%s'", narPath);
7981
auto source = FdSource{fd.get()};
8082
auto narAccessor = makeNarAccessor(source);
8183
auto listing = listNar(narAccessor, CanonPath::root, true);

src/nix/ls.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ struct CmdLsNar : Command, MixLs
146146
void run() override
147147
{
148148
AutoCloseFD fd = open(narPath.c_str(), O_RDONLY);
149+
if (!fd)
150+
throw SysError("opening NAR file '%s'", narPath);
149151
auto source = FdSource{fd.get()};
150152
auto narAccessor = makeNarAccessor(source);
151153
auto listing = listNar(narAccessor, CanonPath::root, true);

0 commit comments

Comments
 (0)