From 6ea601633ef7c2aba24bd4832305005a5f7f4f98 Mon Sep 17 00:00:00 2001 From: Jeremy Stribling Date: Fri, 13 Apr 2018 16:39:03 -0700 Subject: dotgit: ignore filenames that don't match a hash For both packfiles and object files. Issue: keybase/client#11366 Signed-off-by: Jeremy Stribling --- storage/filesystem/internal/dotgit/dotgit.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'storage/filesystem/internal/dotgit/dotgit.go') 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 } -- cgit