libgit2 config opts: set the search to an empty path

Otherwise this would search outside the unveiled paths and cause an unveil
violation.

Reported by Anton Lindqvist, thanks!
This commit is contained in:
Hiltjo Posthuma 2022-01-03 12:21:12 +01:00
parent df2a31c67a
commit 4d19863b06
2 changed files with 8 additions and 0 deletions

View 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)

View file

@ -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)