@@ -40,6 +40,17 @@ static const unsigned char thin_pack[] = {
4040};
4141static const unsigned int thin_pack_len = 78 ;
4242
43+ /*
44+ * Packfile that causes the packfile stream to open in a way in which it leaks
45+ * the stream reader.
46+ */
47+ static const unsigned char leaky_pack [] = {
48+ 0x50 , 0x41 , 0x43 , 0x4b , 0x00 , 0x00 , 0x00 , 0x03 , 0x00 , 0x00 , 0x00 , 0x03 ,
49+ 0xf4 , 0xbd , 0x51 , 0x51 , 0x51 , 0x51 , 0x51 , 0x72 , 0x65 , 0x41 , 0x4b , 0x63 ,
50+ 0x5f , 0x64 , 0x65 , 0x70 , 0x74 , 0x68 , 0xbd , 0x41 , 0x4b
51+ };
52+ static const unsigned int leaky_pack_len = 33 ;
53+
4354static const unsigned char base_obj [] = { 07 , 076 };
4455static const unsigned int base_obj_len = 2 ;
4556
@@ -60,6 +71,22 @@ void test_pack_indexer__out_of_order(void)
6071 git_indexer_free (idx );
6172}
6273
74+ void test_pack_indexer__leaky (void )
75+ {
76+ git_indexer * idx = 0 ;
77+ git_transfer_progress stats = { 0 };
78+
79+ cl_git_pass (git_indexer_new (& idx , "." , 0 , NULL , NULL , NULL ));
80+ cl_git_pass (git_indexer_append (
81+ idx , leaky_pack , leaky_pack_len , & stats ));
82+ cl_git_fail (git_indexer_commit (idx , & stats ));
83+
84+ cl_assert (giterr_last () != NULL );
85+ cl_assert_equal_i (giterr_last ()-> klass , GITERR_INDEXER );
86+
87+ git_indexer_free (idx );
88+ }
89+
6390void test_pack_indexer__fix_thin (void )
6491{
6592 git_indexer * idx = NULL ;
0 commit comments