aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object
diff options
context:
space:
mode:
authoryiteng.nyt <yiteng.nyt@alibaba-inc.com>2023-12-13 15:25:49 +0800
committeryiteng.nyt <yiteng.nyt@alibaba-inc.com>2024-03-08 16:55:28 +0800
commitf5d118c19c0ff1f15e1f5cf9129d1837ecdeee39 (patch)
treef728b6bf0d37375d9fee115d2364129ef4375df6 /plumbing/object
parentefdd3995a97305ade02e482ef99f8b989b5ef55f (diff)
downloadgo-git-f5d118c19c0ff1f15e1f5cf9129d1837ecdeee39.tar.gz
plumbing: object, check filename in (*Tree).Encode
Diffstat (limited to 'plumbing/object')
-rw-r--r--plumbing/object/tree.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/plumbing/object/tree.go b/plumbing/object/tree.go
index e9f7666..7fe773d 100644
--- a/plumbing/object/tree.go
+++ b/plumbing/object/tree.go
@@ -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
}