Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-07-29 12:29:24 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-08-05 07:56:26 +0300
commit7cf4c585866b881883e5e1ac2afaaafcd625c7d9 (patch)
tree83f828639aab58d53d76217c497e5981034d06fd
parentceb9161b1cbf3a6b79fbcd8175159d14a95ab37c (diff)
objectpool: Verify object IDs when rescuing dangling objects
When we rescue dangling objects in an object pool we execute git-fsck(1) to find out about any objects which are not currently referenced. We don't perform any sanity checks though on the output of git-fsck(1): the only thing we do is to split the string, and then pass whatever data we have obtained to git-update-ref(1). Verify that the obtained data is actually a conforming object hash by parsing the object ID. This also prepares for an upcoming change where the updateref package will start to accept `git.ObjectID`s instead of bare strings.
-rw-r--r--internal/git/objectpool/fetch.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/internal/git/objectpool/fetch.go b/internal/git/objectpool/fetch.go
index 0ee7d6d0a..cb7516e5d 100644
--- a/internal/git/objectpool/fetch.go
+++ b/internal/git/objectpool/fetch.go
@@ -250,8 +250,13 @@ func (o *ObjectPool) rescueDanglingObjects(ctx context.Context) error {
continue
}
+ danglingObjectID, err := git.ObjectHashSHA1.FromHex(split[2])
+ if err != nil {
+ return fmt.Errorf("parsing object ID %q: %w", split[2], err)
+ }
+
ref := git.ReferenceName(danglingObjectNamespace + split[2])
- if err := updater.Create(ref, split[2]); err != nil {
+ if err := updater.Create(ref, danglingObjectID.String()); err != nil {
return err
}
}