ref: b373c36d4caecfdbcd6d0833c11092893fcb770c
parent: a6b7833442b430a1db521b0e2d18d2cda1763920
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Oct 9 11:48:32 EDT 2020
walk, query: check for errors on chdir
--- a/query.c
+++ b/query.c
@@ -139,11 +139,14 @@
}ARGEND;
gitinit();
- if(findrepo(repo, sizeof(repo)) == -1)
- sysfatal("find root: %r");
+ fmtinstall('P', Pfmt);
+
if(argc == 0)
usage();
- fmtinstall('P', Pfmt);
+ if(findrepo(repo, sizeof(repo)) == -1)
+ sysfatal("find root: %r");
+ if(chdir(repo) == -1)
+ sysfatal("chdir: %r");
s = "";
p = query;
e = query + nelem(query);
--- a/walk.c
+++ b/walk.c
@@ -238,7 +238,8 @@
sysfatal("no running git/fs");
if(findrepo(repo, sizeof(repo)) == -1)
sysfatal("find root: %r");
- chdir(repo);
+ if(chdir(repo) == -1)
+ sysfatal("chdir: %r");
dirty = 0;
memset(&r, 0, sizeof(r));
if(access("/mnt/git/ctl", AEXIST) != 0)