configfile: return specific error on empty input

Report the actual problem instead of a generic
"unexpected end of JSON input".

https://github.com/rfjakob/gocryptfs/issues/258
This commit is contained in:
Jakob Unterwurzacher 2018-09-08 12:18:26 +02:00
parent 22906cc5fa
commit 21eaa8f164
1 changed files with 3 additions and 0 deletions

View File

@ -133,6 +133,9 @@ func Load(filename string, password []byte) ([]byte, *ConfFile, error) {
if err != nil {
return nil, nil, err
}
if len(js) == 0 {
return nil, nil, fmt.Errorf("Config file is empty")
}
// Unmarshal
err = json.Unmarshal(js, &cf)