File tree Expand file tree Collapse file tree 2 files changed +8
-17
lines changed Expand file tree Collapse file tree 2 files changed +8
-17
lines changed Original file line number Diff line number Diff line change @@ -169,10 +169,6 @@ func (fs *ChrootHelper) Symlink(target, link string) error {
169
169
target = filepath .Clean (filepath .FromSlash (target ))
170
170
}
171
171
172
- if fs .isTargetOutBounders (link , target ) {
173
- return billy .ErrCrossedBoundary
174
- }
175
-
176
172
link , err := fs .underlyingPath (link )
177
173
if err != nil {
178
174
return err
@@ -181,17 +177,6 @@ func (fs *ChrootHelper) Symlink(target, link string) error {
181
177
return fs .underlying .(billy.Symlink ).Symlink (target , link )
182
178
}
183
179
184
- func (fs * ChrootHelper ) isTargetOutBounders (link , target string ) bool {
185
- fulllink := fs .Join (fs .base , link )
186
- fullpath := fs .Join (filepath .Dir (fulllink ), target )
187
- target , err := filepath .Rel (fs .base , fullpath )
188
- if err != nil {
189
- return true
190
- }
191
-
192
- return isCrossBoundaries (target )
193
- }
194
-
195
180
func (fs * ChrootHelper ) Readlink (link string ) (string , error ) {
196
181
fullpath , err := fs .underlyingPath (link )
197
182
if err != nil {
Original file line number Diff line number Diff line change @@ -104,8 +104,14 @@ func (s *FilesystemSuite) TestSymlinkWithChrootBasic(c *C) {
104
104
105
105
func (s * FilesystemSuite ) TestSymlinkWithChrootCrossBounders (c * C ) {
106
106
qux , _ := s .FS .Chroot ("/qux" )
107
- err := qux .(Filesystem ).Symlink ("../../file" , "qux/link" )
108
- c .Assert (err , Equals , ErrCrossedBoundary )
107
+ util .WriteFile (s .FS , "file" , []byte ("foo" ), customMode )
108
+
109
+ err := qux .Symlink ("../../file" , "qux/link" )
110
+ c .Assert (err , Equals , nil )
111
+
112
+ fi , err := qux .Stat ("qux/link" )
113
+ c .Assert (fi , NotNil )
114
+ c .Assert (err , Equals , nil )
109
115
}
110
116
111
117
func (s * FilesystemSuite ) TestReadDirWithLink (c * C ) {
You can’t perform that action at this time.
0 commit comments