summaryrefslogtreecommitdiff
path: root/tests/patch/parse.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2019-10-19 15:52:35 +0200
committerPatrick Steinhardt <ps@pks.im>2019-10-19 17:06:11 +0200
commit6c6c15e935091a33f83d8de4ee5b0640339b2b89 (patch)
tree114c5b1478590bdd91d052d464baf7667ac3d4b0 /tests/patch/parse.c
parent223e7e43efffdcab4da864413e70eff40e8ada46 (diff)
downloadlibgit2-6c6c15e935091a33f83d8de4ee5b0640339b2b89.tar.gz
patch_parse: reject empty path names
When parsing patch headers, we currently accept empty path names just fine, e.g. a line "--- \n" would be parsed as the empty filename. This is not a valid patch format and may cause `NULL` pointer accesses at a later place as `git_buf_detach` will return `NULL` in that case. Reject such patches as malformed with a nice error message.
Diffstat (limited to 'tests/patch/parse.c')
-rw-r--r--tests/patch/parse.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/patch/parse.c b/tests/patch/parse.c
index fb185eb2a..ede5a96e2 100644
--- a/tests/patch/parse.c
+++ b/tests/patch/parse.c
@@ -149,6 +149,13 @@ void test_patch_parse__lifetime_of_patch_does_not_depend_on_buffer(void)
git_patch_free(patch);
}
+void test_patch_parse__binary_file_with_missing_paths(void)
+{
+ git_patch *patch;
+ cl_git_fail(git_patch_from_buffer(&patch, PATCH_BINARY_FILE_WITH_MISSING_PATHS,
+ strlen(PATCH_BINARY_FILE_WITH_MISSING_PATHS), NULL));
+}
+
void test_patch_parse__memory_leak_on_multiple_paths(void)
{
git_patch *patch;