Skip to content

Commit

Permalink
plumbing: object, report malformed filename in (*Tree).Encode
Browse files Browse the repository at this point in the history
  • Loading branch information
niukuo committed Dec 13, 2023
1 parent 952f1ba commit 7efd982
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions plumbing/object/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ func (t *Tree) Encode(o plumbing.EncodedObject) (err error) {

defer ioutil.CheckClose(w, &err)
for _, entry := range t.Entries {
if strings.IndexByte(entry.Name, 0) != -1 {
return fmt.Errorf("malformed filename '%s'", entry.Name)
}
if _, err = fmt.Fprintf(w, "%o %s", entry.Mode, entry.Name); err != nil {
return err
}
Expand Down

0 comments on commit 7efd982

Please sign in to comment.