libgit2 config opts: set the search to an empty path
authorHiltjo Posthuma <hiltjo@codemadness.org>
Mon, 3 Jan 2022 11:21:12 +0000 (12:21 +0100)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Mon, 3 Jan 2022 11:22:52 +0000 (12:22 +0100)
Otherwise this would search outside the unveiled paths and cause an unveil
violation.

Reported by Anton Lindqvist, thanks!

stagit-index.c
stagit.c

index 087ae1e95023430256c6adce8315e68bdd740ff9..7c1f76da0f015bf04e940d413bc670ad25423831 100644 (file)
@@ -173,7 +173,11 @@ main(int argc, char *argv[])
                return 1;
        }
 
+       /* do not search outside the git repository:
+          GIT_CONFIG_LEVEL_APP is the highest level currently */
        git_libgit2_init();
+       for (i = 1; i <= GIT_CONFIG_LEVEL_APP; i++)
+               git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, i, "");
 
 #ifdef __OpenBSD__
        if (pledge("stdio rpath", NULL) == -1)
index 22fc2aa3c2d71d0825675afffa7408691d2e6a82..0d53b72e637a96302e0975cd095826b4e2a6948e 100644 (file)
--- a/stagit.c
+++ b/stagit.c
@@ -1220,7 +1220,11 @@ main(int argc, char *argv[])
        if (!realpath(repodir, repodirabs))
                err(1, "realpath");
 
+       /* do not search outside the git repository:
+          GIT_CONFIG_LEVEL_APP is the highest level currently */
        git_libgit2_init();
+       for (i = 1; i <= GIT_CONFIG_LEVEL_APP; i++)
+               git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, i, "");
 
 #ifdef __OpenBSD__
        if (unveil(repodir, "r") == -1)