TreeEntryFile returns the *File for a given *TreeEntry. The entry's name is validated against pathutil.ValidTreePath for the same reason FindEntry validates: TreeEntryFile is a boundary where attacker-controlled tree data leaves the trusted store as a *File whose Name a caller can hand to filesyste
(e *TreeEntry)
| 125 | // where attacker-controlled tree data leaves the trusted store as a |
| 126 | // *File whose Name a caller can hand to filesystem ops. |
| 127 | func (t *Tree) TreeEntryFile(e *TreeEntry) (*File, error) { |
| 128 | if err := pathutil.ValidTreePath(e.Name); err != nil { |
| 129 | return nil, err |
| 130 | } |
| 131 | |
| 132 | blob, err := GetBlob(t.s, e.Hash) |
| 133 | if err != nil { |
| 134 | return nil, err |
| 135 | } |
| 136 | |
| 137 | return NewFile(e.Name, e.Mode, blob), nil |
| 138 | } |
| 139 | |
| 140 | // FindEntry search a TreeEntry in this tree or any subtree. |
| 141 | // |
no test coverage detected