diff --git a/peer/storage.go b/peer/storage.go index 57120ba..68db73b 100644 --- a/peer/storage.go +++ b/peer/storage.go @@ -5,6 +5,7 @@ import ( "compress/gzip" "crypto/rand" "database/sql" + "encoding/hex" "errors" "fmt" "git.openprivacy.ca/openprivacy/log" @@ -238,6 +239,11 @@ func checkCwtchProfileBackupFile(srcFile string) (string, error) { dir := parts[0] profileFileType := parts[1] + _, hexErr := hex.DecodeString(dir) + if dir == "." || dir == ".." || len(dir) !=32 || hexErr != nil { + return "", errors.New("invalid profile name") + } + if profileName == "" { profileName = dir } @@ -293,6 +299,12 @@ func importCwtchProfileBackupFile(srcFile string, profilesDir string) error { } dir := parts[0] base := parts[1] + + _, hexErr := hex.DecodeString(dir) + if dir == "." || dir == ".." || len(dir) != 32 || hexErr != nil { + return errors.New("invalid profile name") + } + if profileName == "" { profileName = dir }