Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plumbing: object, check legitimacy in (*Tree).Encode #967

Merged
merged 2 commits into from
Mar 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
plumbing: object, check filename in (*Tree).Encode
  • Loading branch information
niukuo committed Mar 8, 2024
commit f5d118c19c0ff1f15e1f5cf9129d1837ecdeee39
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 %q", entry.Name)
}
if _, err = fmt.Fprintf(w, "%o %s", entry.Mode, entry.Name); err != nil {
return err
}
Expand Down