1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-07 11:03:15 +00:00

config: prevent use of windows reserved names in config file name

This commit is contained in:
albertony
2021-04-08 20:59:15 +02:00
parent 23a0d4a1e6
commit f2d3264054
4 changed files with 77 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ import (
"github.com/rclone/rclone/fs/config/obscure"
"github.com/rclone/rclone/fs/fspath"
"github.com/rclone/rclone/fs/rc"
"github.com/rclone/rclone/lib/file"
"github.com/rclone/rclone/lib/random"
)
@@ -226,16 +227,20 @@ func GetConfigPath() string {
//
// Checks for empty string, os null device, or special path, all of which indicates in-memory config.
func SetConfigPath(path string) (err error) {
var cfgPath string
if path == "" || path == os.DevNull {
configPath = ""
cfgPath = ""
} else if err = file.IsReserved(path); err != nil {
return err
} else {
if configPath, err = filepath.Abs(path); err != nil {
if cfgPath, err = filepath.Abs(path); err != nil {
return err
}
if configPath == noConfigPath {
configPath = ""
if cfgPath == noConfigPath {
cfgPath = ""
}
}
configPath = cfgPath
return nil
}