diff options
author | Russell Belfer <rb@github.com> | 2014-05-12 10:44:13 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-05-12 10:44:13 -0700 |
commit | af567e8853e359df3b3abb7d3f7c15c3b1b391c7 (patch) | |
tree | b107914c977657dbe32c76cedea7d44e88f80a8d /tests | |
parent | ce3b71d91b9cac3b462dec9ac2c7e397b55c00a6 (diff) | |
parent | 1e4976cb015bd10a2a8c377e02801306473afc26 (diff) | |
download | libgit2-af567e8853e359df3b3abb7d3f7c15c3b1b391c7.tar.gz |
Merge pull request #2334 from libgit2/rb/fix-2333
Be more careful with user-supplied buffers
Diffstat (limited to 'tests')
-rw-r--r-- | tests/object/blob/filter.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/object/blob/filter.c b/tests/object/blob/filter.c index 9798055cd..0aaaee6f3 100644 --- a/tests/object/blob/filter.c +++ b/tests/object/blob/filter.c @@ -112,7 +112,7 @@ void test_object_blob_filter__to_odb(void) git_config *cfg; int i; git_blob *blob; - git_buf out = GIT_BUF_INIT; + git_buf out = GIT_BUF_INIT, zeroed; cl_git_pass(git_repository_config(&cfg, g_repo)); cl_assert(cfg); @@ -127,13 +127,20 @@ void test_object_blob_filter__to_odb(void) for (i = 0; i < CRLF_NUM_TEST_OBJECTS; i++) { cl_git_pass(git_blob_lookup(&blob, g_repo, &g_crlf_oids[i])); + /* try once with allocated blob */ cl_git_pass(git_filter_list_apply_to_blob(&out, fl, blob)); - cl_assert_equal_sz(g_crlf_filtered[i].size, out.size); - cl_assert_equal_i( 0, memcmp(out.ptr, g_crlf_filtered[i].ptr, out.size)); + /* try again with zeroed blob */ + memset(&zeroed, 0, sizeof(zeroed)); + cl_git_pass(git_filter_list_apply_to_blob(&zeroed, fl, blob)); + cl_assert_equal_sz(g_crlf_filtered[i].size, zeroed.size); + cl_assert_equal_i( + 0, memcmp(zeroed.ptr, g_crlf_filtered[i].ptr, zeroed.size)); + git_buf_free(&zeroed); + git_blob_free(blob); } |