mirror of
https://git.proxmox.com/git/libgit2
synced 2026-01-04 21:21:02 +00:00
Merge pull request #1270 from libgit2/packed-peeled-objects-fix
Allow peeled references without trailing newline at end of file
This commit is contained in:
commit
8958fad770
12
src/refs.c
12
src/refs.c
@ -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);
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
# pack-refs with: peeled
|
||||
eda9f45a2a98d4c17a09d681d88569fa4ea91755 refs/tags/e90810b
|
||||
^e90810b8df3e80c413d903f631643c716887138d
|
||||
d3bacb8d3ff25876a961b1963b6515170d0151ab refs/tags/hello
|
||||
^6dcf9bf7541ee10456529833502442f385010c3d
|
||||
Loading…
Reference in New Issue
Block a user