diff options
| author | Patrick Steinhardt <ps@pks.im> | 2019-10-19 15:52:35 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2019-10-19 17:06:11 +0200 |
| commit | 6c6c15e935091a33f83d8de4ee5b0640339b2b89 (patch) | |
| tree | 114c5b1478590bdd91d052d464baf7667ac3d4b0 /tests/patch/parse.c | |
| parent | 223e7e43efffdcab4da864413e70eff40e8ada46 (diff) | |
| download | libgit2-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.c | 7 |
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; |
