MDL-57801 core_filestorage: Verify hash of temp file before committing
This addresses an edge scenario on NFS filesystems with no space remaining, where subsequent uploads fail silently while zero byte files are saved to the pool (and for some reason the filesize check passes).
This commit is contained in:
@@ -2004,9 +2004,9 @@ class file_storage {
|
||||
ignore_user_abort($prev);
|
||||
throw new file_exception('storedfilecannotcreatefile');
|
||||
}
|
||||
if (filesize($hashfile.'.tmp') !== $filesize) {
|
||||
// This should not happen.
|
||||
unlink($hashfile.'.tmp');
|
||||
if (sha1_file($hashfile.'.tmp') !== $contenthash) {
|
||||
// Highly unlikely edge case, but this can happen on an NFS volume with no space remaining.
|
||||
@unlink($hashfile.'.tmp');
|
||||
ignore_user_abort($prev);
|
||||
throw new file_exception('storedfilecannotcreatefile');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user