Commit 289aaa41 by Edward Thomson

ignore: validate workdir paths for ignore files

parent 9fb755d5
...@@ -309,12 +309,17 @@ int git_ignore__for_path( ...@@ -309,12 +309,17 @@ int git_ignore__for_path(
if ((error = git_path_dirname_r(&local, path)) < 0 || if ((error = git_path_dirname_r(&local, path)) < 0 ||
(error = git_path_resolve_relative(&local, 0)) < 0 || (error = git_path_resolve_relative(&local, 0)) < 0 ||
(error = git_path_to_dir(&local)) < 0 || (error = git_path_to_dir(&local)) < 0 ||
(error = git_buf_joinpath(&ignores->dir, workdir, local.ptr)) < 0) (error = git_buf_joinpath(&ignores->dir, workdir, local.ptr)) < 0 ||
{;} /* Nothing, we just want to stop on the first error */ (error = git_path_validate_workdir_buf(repo, &ignores->dir)) < 0) {
/* Nothing, we just want to stop on the first error */
}
git_buf_dispose(&local); git_buf_dispose(&local);
} else { } else {
error = git_buf_joinpath(&ignores->dir, path, ""); if (!(error = git_buf_joinpath(&ignores->dir, path, "")))
error = git_path_validate_filesystem(ignores->dir.ptr, ignores->dir.size);
} }
if (error < 0) if (error < 0)
goto cleanup; goto cleanup;
...@@ -590,7 +595,7 @@ int git_ignore__check_pathspec_for_exact_ignores( ...@@ -590,7 +595,7 @@ int git_ignore__check_pathspec_for_exact_ignores(
git_attr_fnmatch *match; git_attr_fnmatch *match;
int ignored; int ignored;
git_buf path = GIT_BUF_INIT; git_buf path = GIT_BUF_INIT;
const char *wd, *filename; const char *filename;
git_index *idx; git_index *idx;
if ((error = git_repository__ensure_not_bare( if ((error = git_repository__ensure_not_bare(
...@@ -598,8 +603,6 @@ int git_ignore__check_pathspec_for_exact_ignores( ...@@ -598,8 +603,6 @@ int git_ignore__check_pathspec_for_exact_ignores(
(error = git_repository_index(&idx, repo)) < 0) (error = git_repository_index(&idx, repo)) < 0)
return error; return error;
wd = git_repository_workdir(repo);
git_vector_foreach(vspec, i, match) { git_vector_foreach(vspec, i, match) {
/* skip wildcard matches (if they are being used) */ /* skip wildcard matches (if they are being used) */
if ((match->flags & GIT_ATTR_FNMATCH_HASWILD) != 0 && if ((match->flags & GIT_ATTR_FNMATCH_HASWILD) != 0 &&
...@@ -612,7 +615,7 @@ int git_ignore__check_pathspec_for_exact_ignores( ...@@ -612,7 +615,7 @@ int git_ignore__check_pathspec_for_exact_ignores(
if (git_index_get_bypath(idx, filename, 0) != NULL) if (git_index_get_bypath(idx, filename, 0) != NULL)
continue; continue;
if ((error = git_buf_joinpath(&path, wd, filename)) < 0) if ((error = git_repository_workdir_path(&path, repo, filename)) < 0)
break; break;
/* is there a file on disk that matches this exactly? */ /* is there a file on disk that matches this exactly? */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment