Properly remove bad profile dir #435

Merged
dan merged 2 commits from import_export into master 2022-03-09 23:58:37 +00:00
1 changed files with 12 additions and 0 deletions
Showing only changes of commit ff91300c39 - Show all commits

View File

@ -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
}