heal: Check for truncated files (#10399)

When checking parts we already do a stat for each part.

Since we have the on disk size check if it is at least what we expect.

When checking metadata check if metadata is 0 bytes.
master
Klaus Post 4 years ago committed by GitHub
parent a89d6b8e3d
commit 3e1fb17b70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      cmd/xl-storage.go

@ -1812,6 +1812,10 @@ func (s *xlStorage) CheckParts(volume, path string, fi FileInfo) error {
if st.Mode().IsDir() {
return errFileNotFound
}
// Check if shard is truncated.
if st.Size() < fi.Erasure.ShardFileSize(part.Size) {
return errFileCorrupt
}
}
return nil
@ -1860,7 +1864,7 @@ func (s *xlStorage) CheckFile(volume, path string) error {
}
// If its a directory its not a regular file.
if st.Mode().IsDir() {
if st.Mode().IsDir() || st.Size() == 0 {
return errFileNotFound
}

Loading…
Cancel
Save