lib/protocol: Set invalid flag on encrypted file infos (fixes #7466) (#7467)

This commit is contained in:
Simon Frei 2021-03-13 16:57:36 +01:00 committed by GitHub
parent a12ede3bbe
commit f80ee472c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View File

@ -314,6 +314,7 @@ func encryptFileInfo(fi FileInfo, folderKey *[keySize]byte) FileInfo {
Permissions: 0644, Permissions: 0644,
ModifiedS: 1234567890, // Sat Feb 14 00:31:30 CET 2009 ModifiedS: 1234567890, // Sat Feb 14 00:31:30 CET 2009
Deleted: fi.Deleted, Deleted: fi.Deleted,
RawInvalid: fi.IsInvalid(),
Version: version, Version: version,
Sequence: fi.Sequence, Sequence: fi.Sequence,
RawBlockSize: fi.RawBlockSize + blockOverhead, RawBlockSize: fi.RawBlockSize + blockOverhead,

View File

@ -113,9 +113,8 @@ func TestEnDecryptBytes(t *testing.T) {
} }
} }
func TestEnDecryptFileInfo(t *testing.T) { func encFileInfo() FileInfo {
var key [32]byte return FileInfo{
fi := FileInfo{
Name: "hello", Name: "hello",
Size: 45, Size: 45,
Permissions: 0755, Permissions: 0755,
@ -133,6 +132,11 @@ func TestEnDecryptFileInfo(t *testing.T) {
}, },
}, },
} }
}
func TestEnDecryptFileInfo(t *testing.T) {
var key [32]byte
fi := encFileInfo()
enc := encryptFileInfo(fi, &key) enc := encryptFileInfo(fi, &key)
if bytes.Equal(enc.Blocks[0].Hash, enc.Blocks[1].Hash) { if bytes.Equal(enc.Blocks[0].Hash, enc.Blocks[1].Hash) {
@ -155,6 +159,21 @@ func TestEnDecryptFileInfo(t *testing.T) {
} }
} }
func TestEncryptedFileInfoConsistency(t *testing.T) {
var key [32]byte
files := []FileInfo{
encFileInfo(),
encFileInfo(),
}
files[1].SetIgnored()
for i, f := range files {
enc := encryptFileInfo(f, &key)
if err := checkFileInfoConsistency(enc); err != nil {
t.Errorf("%v: %v", i, err)
}
}
}
func TestIsEncryptedParent(t *testing.T) { func TestIsEncryptedParent(t *testing.T) {
comp := rand.String(maxPathComponent) comp := rand.String(maxPathComponent)
cases := []struct { cases := []struct {