Commit 8958fad7 by Russell Belfer

Merge pull request #1270 from libgit2/packed-peeled-objects-fix

Allow peeled references without trailing newline at end of file
parents f0f073b7 5c7b77c4
......@@ -328,7 +328,7 @@ static int packed_parse_peel(
if (git__prefixcmp(tag_ref->name, GIT_REFS_TAGS_DIR) != 0)
goto corrupt;
if (buffer + GIT_OID_HEXSZ >= buffer_end)
if (buffer + GIT_OID_HEXSZ > buffer_end)
goto corrupt;
/* Is this a valid object id? */
......@@ -339,10 +339,14 @@ static int packed_parse_peel(
if (*buffer == '\r')
buffer++;
if (*buffer != '\n')
goto corrupt;
if (buffer != buffer_end) {
if (*buffer == '\n')
buffer++;
else
goto corrupt;
}
*buffer_out = buffer + 1;
*buffer_out = buffer;
return 0;
corrupt:
......
......@@ -81,6 +81,7 @@ void test_object_tag_read__parse_without_tagger(void)
cl_assert(git_oid_cmp(&id_commit, git_commit_id(commit)) == 0);
git_tag_free(bad_tag);
git_commit_free(commit);
git_repository_free(bad_tag_repo);
......
......@@ -34,3 +34,14 @@ void test_refs_listall__from_repository_opened_through_gitdir_path(void)
{
ensure_no_refname_starts_with_a_forward_slash(cl_fixture("testrepo.git"));
}
void test_refs_listall__from_repository_with_no_trailing_newline(void)
{
cl_git_pass(git_repository_open(&repo, cl_fixture("bad_tag.git")));
cl_git_pass(git_reference_list(&ref_list, repo, GIT_REF_LISTALL));
cl_assert(ref_list.count > 0);
git_strarray_free(&ref_list);
git_repository_free(repo);
}
# pack-refs with: peeled
eda9f45a2a98d4c17a09d681d88569fa4ea91755 refs/tags/e90810b
^e90810b8df3e80c413d903f631643c716887138d
d3bacb8d3ff25876a961b1963b6515170d0151ab refs/tags/hello
^6dcf9bf7541ee10456529833502442f385010c3d
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment