Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit da1231f

Browse files
committed
dotgit: ignore filenames that don't match a hash
For both packfiles and object files. Issue: keybase/client#11366
1 parent 0db54e8 commit da1231f

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

storage/filesystem/internal/dotgit/dotgit.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,11 @@ func (d *DotGit) ObjectPacks() ([]plumbing.Hash, error) {
162162

163163
n := f.Name()
164164
h := plumbing.NewHash(n[5 : len(n)-5]) //pack-(hash).pack
165+
if h.IsZero() {
166+
// Ignore files with badly-formatted names.
167+
continue
168+
}
165169
packs = append(packs, h)
166-
167170
}
168171

169172
return packs, nil
@@ -255,7 +258,12 @@ func (d *DotGit) ForEachObjectHash(fun func(plumbing.Hash) error) error {
255258
}
256259

257260
for _, o := range d {
258-
err = fun(plumbing.NewHash(base + o.Name()))
261+
h := plumbing.NewHash(base + o.Name())
262+
if h.IsZero() {
263+
// Ignore files with badly-formatted names.
264+
continue
265+
}
266+
err = fun(h)
259267
if err != nil {
260268
return err
261269
}

0 commit comments

Comments
 (0)