Commit dbc03de4 by Edward Thomson

apply: ensure we validate paths

There was no test ensuring that we validate `.git` paths.  We do, but
let's add a test to make sure that we never regress this.
parent dc1ba018
......@@ -1923,7 +1923,7 @@ GIT_INLINE(bool) should_validate_longpaths(git_repository *repo)
int git_path_validate_workdir(git_repository *repo, const char *path)
{
if (should_validate_longpaths(repo))
return git_path_validate_ondisk(path, strlen(path));
return git_path_validate_filesystem(path, strlen(path));
return 0;
}
......@@ -1934,7 +1934,7 @@ int git_path_validate_workdir_with_len(
size_t path_len)
{
if (should_validate_longpaths(repo))
return git_path_validate_ondisk(path, path_len);
return git_path_validate_filesystem(path, path_len);
return 0;
}
......
......@@ -474,6 +474,15 @@
"-asparagus which had been laid by, boil it until these last articles are\n" \
"-sufficiently done, thicken with flour, butter and milk, and serve it up.\n"
#define DIFF_ADD_INVALID_FILENAME \
"diff --git a/.git/hello_world.txt b/.git/hello_world.txt\n" \
"new file mode 100644\n" \
"index 0000000..f75ba05\n" \
"--- /dev/null\n" \
"+++ b/.git/hello_world.txt\n" \
"@@ -0,0 +1 @@\n" \
"+Hello, world.\n"
void validate_apply_workdir(
git_repository *repo,
struct merge_index_entry *workdir_entries,
......
......@@ -734,3 +734,14 @@ void test_apply_both__cant_remove_file_twice(void)
git_diff_free(diff);
}
void test_apply_both__cant_add_invalid_filename(void)
{
git_diff *diff;
cl_git_pass(git_diff_from_buffer(&diff, DIFF_ADD_INVALID_FILENAME,
strlen(DIFF_ADD_INVALID_FILENAME)));
cl_git_fail(git_apply(repo, diff, GIT_APPLY_LOCATION_BOTH, NULL));
git_diff_free(diff);
}
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