aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorJeremy Stribling <strib@alum.mit.edu>2018-04-13 16:39:03 -0700
committerJeremy Stribling <strib@alum.mit.edu>2018-04-13 16:56:24 -0700
commit6ea601633ef7c2aba24bd4832305005a5f7f4f98 (patch)
treebf571fb546c00d0da56b8590fcee00b1a590ad39 /storage
parent0db54e829f81a28f71c22d54c03daba5ec144c8d (diff)
downloadgo-git-6ea601633ef7c2aba24bd4832305005a5f7f4f98.tar.gz
dotgit: ignore filenames that don't match a hash
For both packfiles and object files. Issue: keybase/client#11366 Signed-off-by: Jeremy Stribling <strib@alum.mit.edu>
Diffstat (limited to 'storage')
-rw-r--r--storage/filesystem/internal/dotgit/dotgit.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go
index 6f0f1a5..52b621c 100644
--- a/storage/filesystem/internal/dotgit/dotgit.go
+++ b/storage/filesystem/internal/dotgit/dotgit.go
@@ -162,8 +162,11 @@ func (d *DotGit) ObjectPacks() ([]plumbing.Hash, error) {
n := f.Name()
h := plumbing.NewHash(n[5 : len(n)-5]) //pack-(hash).pack
+ if h.IsZero() {
+ // Ignore files with badly-formatted names.
+ continue
+ }
packs = append(packs, h)
-
}
return packs, nil
@@ -255,7 +258,12 @@ func (d *DotGit) ForEachObjectHash(fun func(plumbing.Hash) error) error {
}
for _, o := range d {
- err = fun(plumbing.NewHash(base + o.Name()))
+ h := plumbing.NewHash(base + o.Name())
+ if h.IsZero() {
+ // Ignore files with badly-formatted names.
+ continue
+ }
+ err = fun(h)
if err != nil {
return err
}