From ce72e399d26a7b246f6425657b0c8a55d40159c9 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 5 May 2013 16:45:38 +0200 Subject: [PATCH 1/2] commit: guard create() against not owned trees --- src/commit.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/commit.c b/src/commit.c index 46c02c292..aec3e1e63 100644 --- a/src/commit.c +++ b/src/commit.c @@ -149,6 +149,7 @@ int git_commit_create( const git_oid **parent_oids; assert(parent_count >= 0); + assert(git_object_owner((const git_object *)tree) == repo); parent_oids = git__malloc(parent_count * sizeof(git_oid *)); GITERR_CHECK_ALLOC(parent_oids); From 467cbec73d1c34c3f6c1e7ea66e1276e5e44299b Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 5 May 2013 16:48:34 +0200 Subject: [PATCH 2/2] commit: make create_from_oids() accept plain oid --- include/git2/sys/commit.h | 5 +++-- src/commit.c | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/git2/sys/commit.h b/include/git2/sys/commit.h index 096e028c5..34a12fb15 100644 --- a/include/git2/sys/commit.h +++ b/include/git2/sys/commit.h @@ -25,8 +25,9 @@ GIT_BEGIN_DECL * * See documentation for `git_commit_create()` for information about the * parameters, as the meaning is identical excepting that `tree` and - * `parents` now take `git_oid`. This is a dangerous API in that the - * `parents` list of `git_oid`s in not checked for validity. + * `parents` now take `git_oid`. This is a dangerous API in that nor + * the `tree`, neither the `parents` list of `git_oid`s are checked for + * validity. */ GIT_EXTERN(int) git_commit_create_from_oids( git_oid *oid, diff --git a/src/commit.c b/src/commit.c index aec3e1e63..3dc647c9b 100644 --- a/src/commit.c +++ b/src/commit.c @@ -96,7 +96,6 @@ int git_commit_create_from_oids( git_odb *odb; assert(oid && repo && tree && parent_count >= 0); - assert(git_object_owner((const git_object *)tree) == repo); git_oid__writebuf(&commit, "tree ", tree);