Skip to content

Commit e34063c

Browse files
authored
Merge pull request #14283 from NixOS/nar-check
nix {cat,ls}: Add back missing checks for file descriptors
2 parents 64c5596 + e457ea7 commit e34063c

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)