Skip to content

Commit

Permalink
Merge pull request #36691 from nextcloud/fix/25175/fix-config-truncating
Browse files Browse the repository at this point in the history
add a disk_free_space check before writing config
  • Loading branch information
szaimen authored Feb 15, 2023
2 parents a747be3 + 3757b34 commit 228911c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/private/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ private function writeData() {
'This can usually be fixed by giving the webserver write access to the config directory.');
}

// Never write file back if disk space should be too low
$df = disk_free_space($this->configDir);
$size = strlen($content) + 10240;
if ($df !== false && (int)$df < $size) {
throw new \Exception($this->configDir . " does not have enough space for writing the config file! Not writing it back!");
}

// Try to acquire a file lock
if (!flock($filePointer, LOCK_EX)) {
throw new \Exception(sprintf('Could not acquire an exclusive lock on the config file %s', $this->configFilePath));
Expand Down

0 comments on commit 228911c

Please sign in to comment.