File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ :bug: Ensure that there is an explicit check that a path is not a directory before unlinking
Original file line number Diff line number Diff line change @@ -22,14 +22,21 @@ type ExtendedOsFs struct {
2222}
2323
2424func (c * ExtendedOsFs ) Remove (name string ) (err error ) {
25- // The following is to ensure sockets are correctly removed
26- // https://stackoverflow.com/questions/16681944/how-to-reliably-unlink-a-unix-domain-socket-in-go-programming-language
27- err = commonerrors .Ignore (ConvertFileSystemError (syscall .Unlink (name )), commonerrors .ErrNotFound )
28- err = commonerrors .IgnoreCorrespondTo (err , "is a directory" )
25+ info , err := c .OsFs .Stat (name )
2926 if err != nil {
27+ err = ConvertFileSystemError (err )
3028 return
3129 }
3230
31+ if ! info .IsDir () {
32+ // The following is to ensure sockets are correctly removed
33+ // https://stackoverflow.com/questions/16681944/how-to-reliably-unlink-a-unix-domain-socket-in-go-programming-language
34+ err = commonerrors .Ignore (ConvertFileSystemError (syscall .Unlink (name )), commonerrors .ErrNotFound )
35+ if err != nil {
36+ return
37+ }
38+ }
39+
3340 err = commonerrors .Ignore (ConvertFileSystemError (c .OsFs .Remove (name )), commonerrors .ErrNotFound )
3441 return
3542}
You can’t perform that action at this time.
0 commit comments