fix: clean file path.

This commit is contained in:
Fernandez Ludovic 2020-02-16 20:26:48 +01:00
parent 6a71a1655e
commit 5005a38227
3 changed files with 7 additions and 4 deletions

View File

@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"time"
"github.com/abronan/valkeyrie/store"
@ -125,7 +126,7 @@ func getCAContent(ca string) ([]byte, error) {
return []byte(ca), nil
}
caContent, err := ioutil.ReadFile(ca)
caContent, err := ioutil.ReadFile(filepath.Clean(ca))
if err != nil {
return nil, err
}

View File

@ -9,6 +9,7 @@ import (
"io"
"log"
"os"
"path/filepath"
"strings"
"github.com/containous/traefik/v2/pkg/provider/acme"
@ -71,7 +72,7 @@ func dumpV2(acmeFile string, baseConfig *dumper.BaseConfig) error {
}
func readJSONFile(acmeFile string, data interface{}) error {
source, err := os.Open(acmeFile)
source, err := os.Open(filepath.Clean(acmeFile))
if err != nil {
return fmt.Errorf("failed to open file %q: %w", acmeFile, err)
}
@ -186,7 +187,7 @@ func manageRename(watcher *fsnotify.Watcher, event fsnotify.Event, acmeFile stri
}
func calculateHash(acmeFile string) ([]byte, error) {
file, err := os.Open(acmeFile)
file, err := os.Open(filepath.Clean(acmeFile))
if err != nil {
return nil, err
}

View File

@ -5,6 +5,7 @@ import (
"compress/gzip"
"io/ioutil"
"log"
"path/filepath"
"time"
"github.com/abronan/valkeyrie"
@ -91,7 +92,7 @@ func putData(backend store.Backend, addrs []string, content []byte) error {
}
func readFile(source string) ([]byte, error) {
content, err := ioutil.ReadFile(source)
content, err := ioutil.ReadFile(filepath.Clean(source))
if err != nil {
return nil, err
}