diff options
| author | lhchavez <lhchavez@lhchavez.com> | 2017-12-06 03:03:18 +0000 |
|---|---|---|
| committer | lhchavez <lhchavez@lhchavez.com> | 2017-12-08 14:37:46 +0000 |
| commit | c8aaba2441315680c60a98c73d538922f5ccd33e (patch) | |
| tree | 390ec6635b7bd2f223380496165e8588ec09b692 /tests/pack | |
| parent | 1bf173c33a217a2e4766d8c144b7935010dfa7d6 (diff) | |
| download | libgit2-c8aaba2441315680c60a98c73d538922f5ccd33e.tar.gz | |
libFuzzer: Fix missing trailer crash
This change fixes an invalid memory access when the trailer is missing /
corrupt.
Found using libFuzzer.
Diffstat (limited to 'tests/pack')
| -rw-r--r-- | tests/pack/indexer.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/pack/indexer.c b/tests/pack/indexer.c index a28ee3e07..4d2d9f60e 100644 --- a/tests/pack/indexer.c +++ b/tests/pack/indexer.c @@ -87,6 +87,23 @@ void test_pack_indexer__leaky(void) git_indexer_free(idx); } +void test_pack_indexer__missing_trailer(void) +{ + git_indexer *idx = 0; + git_transfer_progress stats = { 0 }; + + cl_git_pass(git_indexer_new(&idx, ".", 0, NULL, NULL, NULL)); + /* Truncate a valid packfile */ + cl_git_pass(git_indexer_append( + idx, out_of_order_pack, out_of_order_pack_len - 20, &stats)); + cl_git_fail(git_indexer_commit(idx, &stats)); + + cl_assert(giterr_last() != NULL); + cl_assert_equal_i(giterr_last()->klass, GITERR_INDEXER); + + git_indexer_free(idx); +} + void test_pack_indexer__fix_thin(void) { git_indexer *idx = NULL; |
