aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/conf/store.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-03-05 02:29:41 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-03-05 05:36:21 +0100
commitd539b335e8a7a87dda3da259958bb52183fb760e (patch)
tree55d388c2c0b3bfb6164f564740a8b8881ebdc315 /conf/store.go
parentbuild: musl.cc now offers zips (diff)
downloadwireguard-windows-d539b335e8a7a87dda3da259958bb52183fb760e.tar.xz
wireguard-windows-d539b335e8a7a87dda3da259958bb52183fb760e.zip
conf: validate tunnel name
Diffstat (limited to 'conf/store.go')
-rw-r--r--conf/store.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/conf/store.go b/conf/store.go
index 7c110865..da144a17 100644
--- a/conf/store.go
+++ b/conf/store.go
@@ -36,7 +36,11 @@ func ListConfigNames() ([]string, error) {
if !file.Mode().IsRegular() || file.Mode().Perm()&0444 == 0 {
continue
}
- configs[i] = strings.TrimSuffix(name, configFileSuffix)
+ name = strings.TrimSuffix(name, configFileSuffix)
+ if !TunnelNameIsValid(name) {
+ continue
+ }
+ configs[i] = name
i++
}
return configs[:i], nil
@@ -152,10 +156,16 @@ func NameFromPath(path string) (string, error) {
} else {
name = strings.TrimSuffix(name, configFileUnencryptedSuffix)
}
+ if !TunnelNameIsValid(name) {
+ return "", errors.New("Tunnel name is not valid")
+ }
return name, nil
}
func (config *Config) Save() error {
+ if !TunnelNameIsValid(config.Name) {
+ return errors.New("Tunnel name is not valid")
+ }
configFileDir, err := resolveConfigFileDir()
if err != nil {
return err
@@ -179,6 +189,9 @@ func (config *Config) Save() error {
}
func (config *Config) Path() (string, error) {
+ if !TunnelNameIsValid(config.Name) {
+ return "", errors.New("Tunnel name is not valid")
+ }
configFileDir, err := resolveConfigFileDir()
if err != nil {
return "", err
@@ -187,6 +200,9 @@ func (config *Config) Path() (string, error) {
}
func DeleteName(name string) error {
+ if !TunnelNameIsValid(name) {
+ return errors.New("Tunnel name is not valid")
+ }
configFileDir, err := resolveConfigFileDir()
if err != nil {
return err