gosec: added error handling & path cleaning

This commit is contained in:
Fredrik Grönqvist
2019-12-13 12:51:22 +01:00
parent bf2c550334
commit 8413219dec
2 changed files with 14 additions and 4 deletions
+2 -1
View File
@@ -5,6 +5,7 @@ import (
"io/ioutil"
"net"
"os"
"path/filepath"
log "github.com/sirupsen/logrus"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
@@ -43,7 +44,7 @@ func NewServerConfig(cfgPath string) *ServerConfig {
Users: make(map[string]*UserConfig),
}
f, err := os.Open(cfgPath)
f, err := os.Open(filepath.Clean(cfgPath))
if err == nil {
if err = json.NewDecoder(f).Decode(cfg); err != nil {
log.Fatal(err)