mirror of
https://github.com/rclone/rclone.git
synced 2024-11-23 00:43:49 +01:00
crypt: Prevent the user pointing crypt at itself - fixes #927
This would hopefully have stopped the issues reported in #784 & #929
This commit is contained in:
parent
4482e75f38
commit
473bdad00b
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/ncw/rclone/fs"
|
"github.com/ncw/rclone/fs"
|
||||||
@ -71,6 +72,9 @@ func NewFs(name, rpath string) (fs.Fs, error) {
|
|||||||
return nil, errors.Wrap(err, "failed to make cipher")
|
return nil, errors.Wrap(err, "failed to make cipher")
|
||||||
}
|
}
|
||||||
remote := fs.ConfigFile.MustValue(name, "remote")
|
remote := fs.ConfigFile.MustValue(name, "remote")
|
||||||
|
if strings.HasPrefix(remote, name+":") {
|
||||||
|
return nil, errors.New("can't point crypt remote at itself - check the value of the remote setting")
|
||||||
|
}
|
||||||
// Look for a file first
|
// Look for a file first
|
||||||
remotePath := path.Join(remote, cipher.EncryptFileName(rpath))
|
remotePath := path.Join(remote, cipher.EncryptFileName(rpath))
|
||||||
wrappedFs, err := fs.NewFs(remotePath)
|
wrappedFs, err := fs.NewFs(remotePath)
|
||||||
|
Loading…
Reference in New Issue
Block a user