summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-03-29 19:40:02 +0300
committerVicent Marti <tanoku@gmail.com>2011-03-29 19:58:19 +0300
commit9a53df7e0ac364ccba5bd11e9d6c62091f564397 (patch)
tree3ac900aca2eec9a1206f6fd76bb4e91f86863a14 /src
parent95cde17ca40de7ad7f245c9302f26c5d59f5d873 (diff)
downloadlibgit2-9a53df7e0ac364ccba5bd11e9d6c62091f564397.tar.gz
refs: Don't allow references to inexistent OIDs
Diffstat (limited to 'src')
-rw-r--r--src/refs.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/refs.c b/src/refs.c
index c6508ca8e..81706952a 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -1319,6 +1319,13 @@ int git_reference_set_oid(git_reference *ref, const git_oid *id)
ref_oid = (reference_oid *)ref;
+ assert(ref->owner);
+
+ /* Don't let the user create references to OIDs that
+ * don't exist in the ODB */
+ if (!git_odb_exists(git_repository_database(ref->owner), id))
+ return GIT_ENOTFOUND;
+
/* duplicate the reference;
* this copy will stay on the packfile cache */
if (ref->type & GIT_REF_PACKED) {