From 473bdad00bd63d96eceffa43cedaf31a82e67ae0 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 19 Dec 2016 14:09:59 +0000 Subject: [PATCH] crypt: Prevent the user pointing crypt at itself - fixes #927 This would hopefully have stopped the issues reported in #784 & #929 --- crypt/crypt.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crypt/crypt.go b/crypt/crypt.go index 4bc8136dd..0cae24fb3 100644 --- a/crypt/crypt.go +++ b/crypt/crypt.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "path" + "strings" "sync" "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") } 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 remotePath := path.Join(remote, cipher.EncryptFileName(rpath)) wrappedFs, err := fs.NewFs(remotePath)