Skip to content

Commit

Permalink
dotgit: ignore filenames that don't match a hash
Browse files Browse the repository at this point in the history
For both packfiles and object files.

Issue: keybase/client#11366
  • Loading branch information
strib committed Apr 13, 2018
1 parent 0db54e8 commit da1231f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions storage/filesystem/internal/dotgit/dotgit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit da1231f

Please sign in to comment.