reverse: fix longname decoding bug
This could have caused spurious ENOENT errors. That it did not cause these errors all the time is interesting and probably because an earlier readdir would place the entry in the cache. This masks the bug.
This commit is contained in:
parent
e7f57695a6
commit
d3764b7753
@ -11,6 +11,7 @@ import (
|
||||
"github.com/hanwen/go-fuse/fuse/nodefs"
|
||||
|
||||
"github.com/rfjakob/gocryptfs/internal/nametransform"
|
||||
"github.com/rfjakob/gocryptfs/internal/tlog"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -49,6 +50,7 @@ func (rfs *ReverseFS) findLongnameParent(dir string, dirIV []byte, longname stri
|
||||
absDir := filepath.Join(rfs.args.Cipherdir, dir)
|
||||
dirfd, err := os.Open(absDir)
|
||||
if err != nil {
|
||||
tlog.Warn.Printf("findLongnameParent: opendir failed: %v\n", err)
|
||||
return "", err
|
||||
}
|
||||
dirEntries, err := dirfd.Readdirnames(-1)
|
||||
|
@ -52,9 +52,9 @@ func (rfs *ReverseFS) decryptPath(relPath string) (string, error) {
|
||||
parts := strings.Split(relPath, "/")
|
||||
for i, part := range parts {
|
||||
// Start at the top and recurse
|
||||
currentDir := filepath.Join(parts[:i]...)
|
||||
currentCipherDir := filepath.Join(parts[:i]...)
|
||||
nameType := nametransform.NameType(part)
|
||||
dirIV := derivePathIV(currentDir, ivPurposeDirIV)
|
||||
dirIV := derivePathIV(currentCipherDir, ivPurposeDirIV)
|
||||
var transformedPart string
|
||||
if nameType == nametransform.LongNameNone {
|
||||
transformedPart, err = rfs.nameTransform.DecryptName(part, dirIV)
|
||||
@ -74,7 +74,8 @@ func (rfs *ReverseFS) decryptPath(relPath string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
} else if nameType == nametransform.LongNameContent {
|
||||
transformedPart, err = rfs.findLongnameParent(currentDir, dirIV, part)
|
||||
currentPlainDir := filepath.Join(transformedParts[:i]...)
|
||||
transformedPart, err = rfs.findLongnameParent(currentPlainDir, dirIV, part)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user